Open aral opened 4 months ago
This comes down to \/?
being matched at the end of all patterns in regexparam: https://github.com/aral/regexparam/blob/master/src/index.js#L28
for reference, the path-to-regexp
(and thus Express) handles this by offering a trailing
option: https://github.com/pillarjs/path-to-regexp/blob/140b8248e99c34414910d0d2d6c0e822327e1197/src/index.ts#L577
Use case
I want to have pages on a site that are accessed without a trailing slash forward to the trailing slash version.
Why? To avoid relative URLs to assets in the same folder breaking when the path is missing a trailing slash in the markup (e.g.,
<script src='./index.js'></script>
).See: https://stackoverflow.com/questions/31111257/relative-links-on-pages-without-trailing-slash
Issue
I can’t add separate handlers for '/foo' and '/foo/'.
Results in:
Whereas I would expect it to result in: