Accept regular expressions for matching paths
Closed this issue · 8 comments
Similar to the JS Plugin, allow passing raw regexes instead of path-to-regexp-style path strings.
I just decided to remove support for raw user-defined regexes in the Fragment Plugin, in favor for parsed path strings only. In my tests, almost every regex I created was way too naive compared to the corresponding result of path-to-regexp
.
Actually, new findings!! From the documentation of pathToRegexp:
path A string, array of strings, or a regular expression.
So, actually, route-name-plugin already supports raw regular expressions! :)
...and the "array of strings" part seems to be a great way to simplify the API of the Fragment Plugin ✨
Good to know! That means we can update the JS plugin to use the latest version of path-to-regexp snd simplify the logic as well.
The problem wit the array of strings is we lose the capability of matching direction, no?
No we don't :) ...I have already updated the plugin API docs: https://github.com/swup/fragment-plugin#plugin-api
I see! I misunderstood, then. Nice 🍧
I'll have to update the route name plugin readme to show off all that previously unknown functionality 💦
Closing, as already supported.