-
Notifications
You must be signed in to change notification settings - Fork 42
regex named segments #14
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
Comments
good idea ! what do you think about the following edge case behaviour ? if there are more groups in the regex than there are names in the array that is the second argument: if there are less groups in the regex than there are names in the array that is the second argument: shouldn't break backwards compatibility - which is nice. |
👍 however don't you think it'll be more expressive to not just ignore but:
|
i now think we should consider it a user error if the number of groups and names in the array don't match up. i would like to throw an error in such cases to notify the user of bad usage. i might use http://stackoverflow.com/a/16046903 to detect the number of groups and be able to check for such errors as soon as possible i.e. on pattern creation and not on match (callsites of what do you think ? |
sure, sounds good. |
this is now published in 0.10.0. |
It'll be a nice little addition to have named regex segments, for ex.
new UrlPattern(/^\/user\/(\d+)\//i, ["user_id"])
The text was updated successfully, but these errors were encountered: