use unicode-resilient approach to exclude sub delimiters
Fixes https://github.com/troch/route-node/issues/39 Fixes https://github.com/router5/router5/issues/499
Hello!
I know this library is probably in kind of a "done" state but I noticed some issues with emojis in query params and decided to investigate. In the end it turned out the .replace method breaks apart unicode characters in a way that will later trip up encodeURIComponent.
Iterating over characters as done in this PR ensures that surrogate pairs are kept as-is and thus path building works as expected even when emojis are provided as part of path parameters.
(source)
I also added some tests to demonstrate that this is working as intended.
Cheers
@troch is this fix is supposed to be merged? I've faced an issue described here https://github.com/router5/router5/issues/499 and also waiting for this MR to be resolved🙏