Apply path segment normalization #29
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements path segment normalization discussed in #28.
I don't use the algorithm defined in the spec, but a segment based one, which I suspect will be faster for most use cases.
I have gated the algorithm behind a simple pre-detection
ifcase, causing it to not be executed for something like 99% of URLs.I have also added a somewhat comprehensive test suite, testing many of the edge cases. I also tested this new logic with
hapi, which still passes the test suite. I encountered 2 failing tests withinert. In both cases the test expected a403but got at404instead, due to no longer matching the tested route (as expected). I don't consider this an issue, and I can rework the tests to handle the new logic.