-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
Hey all,
Just tried to have a named segment with an underscore, and found that it wasn't working as expected. I have a sample script and output to have as an example:
#!/usr/bin/env node
const UrlPattern = require('url-pattern');
const pattern = new UrlPattern('/test/:value_here');
console.dir(pattern);
console.log(pattern.match('/test/stuff'));
console.log(pattern.match('/test/stuff_here'));UrlPattern {
isRegex: false,
ast:
[ { tag: 'static', value: '/test/' },
{ tag: 'named', value: 'value' },
{ tag: 'static', value: '_here' } ],
regex: /^\/test\/([a-zA-Z0-9-_~ %]+)_here$/,
names: [ 'value' ] }
null
{ value: 'stuff' }
It seems to be parsing the underscore in the named segment as a static separator by accident.
Metadata
Metadata
Assignees
Labels
No labels