Skip to content
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

Named Segment values don't work with parenthesis and other non alphanumeric chars #42

Closed
jahed opened this issue Aug 27, 2017 · 1 comment

Comments

@jahed
Copy link

jahed commented Aug 27, 2017

I'm not sure why, but parenthesis don't match when using named segments. Here's an example:

> const UrlPattern = require('url-pattern')
undefined
> const pattern = new UrlPattern('/pages/:pageName')
undefined
> pattern.match('/pages')
null
> pattern.match('/pages/Hello World')
{ pageName: 'Hello World' }
> pattern.match('/pages/Hello World (Example)')
null
> pattern.match('/pages/Hello World {Example}')
null

Is this intentional?

@jahed
Copy link
Author

jahed commented Aug 27, 2017

Ah, my bad.

I realised the docs are referring to the value and not the named segment itself!

when matching, a named segment consumes all characters in the regex character set a-zA-Z0-9-_~ %. a >named segment match stops at /, ., ... but not at _, -, , %...

you can change these character sets. click here to see how.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant