kenchris / urlpattern-polyfill

URLPattern polyfill
https://www.npmjs.com/package/urlpattern-polyfill
MIT License
268 stars 31 forks source link

Implement pattern canonicalization. #15

Closed wanderview closed 3 years ago

wanderview commented 3 years ago

(Note, this PR depends on #13 which should be merged first.)

This PR adds canonicalization of pattern strings. This is done via the path-to-regexp encode callback feature. These callbacks are invoked on plain text parts of the pattern string. Values within regular expressions, etc, are not passed to the encode callbacks. This PR provides the appropriate encode callback for each component.

In addition, the check for an ASCII regular expression now must be performed by path-to-regexp itself. This PR updates the modified path-to-regexp to do this. This change is also available in:

https://github.com/wanderview/path-to-regexp/tree/urlpattern-6-ascii-regexp