Thanks for sharing this library, I appreciate its simple approach to routing!
It seems like string parameter matching using resolve() will only match a route if the URL path segment begins with letter. For example, if I have the simple routing below:
This routing will not match in all the scenarios I would expect:
/blogs/xy/new-post :heavy_check_mark:
/blogs/x1/new-post :heavy_check_mark:
/blogs/1x/new-post :x:
/blogs/11/new-post :x:
This seems to be because string routing builds a RegExp for string parameters similar to ([a-zA-Z][a-zA-Z0-9\_\-]*). This pattern only matches if the first character is in [a-zA-Z]. Here's a test link for the regex produced by this example for reference: https://regex101.com/r/0ABtfm/1
I can work around this by using a manual regex test instead, like resolve($path, /\/blogs\/(?<id>\w+)\//)
Thanks for reporting this, and so nicely detailed. I should really have allowed numbers in the named routes. Should be fixed by 72bf30f23d844647079810ea036efa1c572db4d9. I've just bumped it to version 2.0.2.
Thanks for sharing this library, I appreciate its simple approach to routing!
It seems like string parameter matching using
resolve()
will only match a route if the URL path segment begins with letter. For example, if I have the simple routing below:This routing will not match in all the scenarios I would expect:
/blogs/xy/new-post
:heavy_check_mark:/blogs/x1/new-post
:heavy_check_mark:/blogs/1x/new-post
:x:/blogs/11/new-post
:x:This seems to be because string routing builds a RegExp for string parameters similar to
([a-zA-Z][a-zA-Z0-9\_\-]*)
. This pattern only matches if the first character is in[a-zA-Z]
. Here's a test link for the regex produced by this example for reference: https://regex101.com/r/0ABtfm/1I can work around this by using a manual regex test instead, like
resolve($path, /\/blogs\/(?<id>\w+)\//)