-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
var UrlPattern = require("url-pattern")
Is there any way to enforce regex at a segment level?
I have a pattern for username with a @.
The current route matchers are failing with the @.
var pattern = new UrlPattern(':username/:postID');
pattern.match('@stoplion/123');
I think I can build the regex like this..
var pattern = new UrlPattern(/@[a-z0-9][-a-z0-9]+)\/([a-z0-9][-a-z0-9]+)/, ['username', 'postIid']);
The URL itself is very hard to read, and I can't figure out what it is at a glance..
Is it possible to do something like this..
Where you can get the named segments, and then enforce a regex pattern
var pattern = new UrlPattern(':username/:postID', {
username: /@[a-z0-9][-a-z0-9]+/
});
shayonj
Metadata
Metadata
Assignees
Labels
No labels