kitbagjs / router

A type safe router for vuejs
https://router.kitbag.dev
MIT License
173 stars 4 forks source link

fix bug with non-escaped regex characters in route #225

Closed stackoverfloweth closed 2 months ago

stackoverfloweth commented 2 months ago

It was discovered that the route regex service was not escaping regex characters found in the route (outside of params). This meant that something like a period (.) in the path or query was interpreted as ANYTHING, not the literal period as expected.

This PR fixes that bug by instead of using a replace all that only targets param syntax and then passing everything into new RegExp(), we instead slit the whole path by the param syntax. For non params we escape regex chars, for params we continue to use catch all. This means a path like

/here-i$-an-[example]-path/ gets split into an array of ['/here-i$-an-', '[example]', '-path/'], which is then joined together as /here-i\\$-an-.+-path/

netlify[bot] commented 2 months ago

Deploy Preview for kitbag-router ready!

Name Link
Latest commit 42bd09bd66f7ba1aadb0ab618b7b9c3dfd851ebb
Latest deploy log https://app.netlify.com/sites/kitbag-router/deploys/669c1fcca6bc400008141fee
Deploy Preview https://deploy-preview-225--kitbag-router.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.