Multiple parameters suffixed with an asterisk does not match - works with v5/v3
The following pattern used to match:
let re = pathToRegexp("/files/:path*\\.:ext*", paramNames);
let match = "/files/my/photo.jpg/gif".match(re);
Version 3.0 works: https://codesandbox.io/s/old-thunder-x209j3nkko Version 5.0 works: https://codesandbox.io/s/angry-bhaskara-gkzf3 Version 6.1 does not work: https://codesandbox.io/s/naughty-cherry-lgsiz
This is expected behaviour, see https://github.com/pillarjs/path-to-regexp/releases/tag/v6.0.0. Version 3 was the first version to introduce this piece of magic, but for 6.0 stabilizing I wanted to remove things that cause confusion and this was a big one.
According to https://github.com/pillarjs/path-to-regexp/releases/tag/v6.0.0 the v6 should be compatible with v2 but unfortunately is not the case.
In v2, without the period escape the following would match path and ext
See https://codesandbox.io/s/frosty-leftpad-x75l707pxw
let paramNames = [];
let re = pathToRegexp("/files/:path*.:ext*", paramNames);
let match = "/files/my/photo.jpg/gif".match(re);
But in v6 only path is matched:
See https://codesandbox.io/s/path-to-regexp-61-multiple-splat-no-escape-5k2b4
Notice that the period escape was originally suggested in this issue comment.
Ah, thanks. I see the issue. When you escape the previous character now, it ends up without a prefix or suffix effectively making it impossible to actually match a repeated group. We could default to / (configurable) as the prefix to support the existing use-case.
Is there a way to support multiple splat with current features, e.g., adding some more notation?
I don't mind if i need to change the pattern.
@blakeembrey should this be labeled as a valid bug that needs a fix?
Sure. It should be pretty easy to fix, but it'd be good to come up with possible notation too.
This would be fixed by https://github.com/pillarjs/path-to-regexp/pull/270!