troch / route-node

A package to create a tree of named routes
MIT License
20 stars 15 forks source link

Strip content of regexes from path before sorting #14

Closed dgieselaar closed 7 years ago

dgieselaar commented 7 years ago

When a regex contains a question mark (for instance, for an optional parameter, a negative lookahead, or a non-capturing group), the children of the route are not correctly sorted anymore, because they're cut off at the first question mark. This change removes the content of the regex before sorting.

Additionally, I've changed the test command to ensure it runs on Windows as well.

troch commented 7 years ago

Great find, going to merge and release. I'll probably re-visit the sorting solution at some point so that the number of segments comes from path-parser. But will do for now 👍