-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple parameters suffixed with an asterisk does not match - works with v5/v3 #214
Comments
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 let paramNames = [];
let re = pathToRegexp("/files/:path*.:ext*", paramNames);
let match = "/files/my/photo.jpg/gif".match(re); But in v6 only 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 |
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 #270! |
Fixed in V7 by getting rid of implicit prefixes entirely. So in V7, I believe it would be It should also be a bug to have a repeatable parameter without any separator, as |
The following pattern used to match:
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
The text was updated successfully, but these errors were encountered: