swup/route-name-plugin

Accept regular expressions for matching paths

Closed this issue · 8 comments

daun commented

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 ✨

daun commented

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.

daun commented

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

daun commented

I see! I misunderstood, then. Nice 🍧

daun commented

I'll have to update the route name plugin readme to show off all that previously unknown functionality 💦

daun commented

Closing, as already supported.