QubitProducts / cherrytree

A flexible nested router.
MIT License
108 stars 20 forks source link

Encode path parameters #143

Closed nathanboktae closed 8 years ago

nathanboktae commented 8 years ago

A user of ours found a bug where some id put into a path that had / in it was causing the same generated path to not be routable, because the parameters were not being encoded. This PR encodes and decodes them, handing splat params to restore slashes to preserve functionality.

One assertion that didn't make sense was

assert.equals(Path.injectParams('comments/:id?/edit', { id: 'the/id' }), 'comments/the/id/edit')

round-tripping comments/the/id/edit wouldn't even match comments/:id?/edit. Now it will with these changes.

swagatha-christie commented 8 years ago

By analyzing the blame information on this pull request, we identified @KidkArolis to be a potential reviewer

KidkArolis commented 8 years ago

Thanks.