Avoid duplicate trailing delimiter matches#443
Conversation
There was a problem hiding this comment.
I'm not really convinced this is worth doing. No one has run into it as an issue, and while it might be considered a minor correctness issue, the logic of it is "simple" today. The change has to land in a major just to be sure no one is relying on it accidentally. If we can do it without any change in overall bytes I'd consider it.
|
@vibhor-aggr thanks; here's hoping this PR goes well and eventually gets in. Very nice that its requires only a few lines. |
|
Thanks for the review. I moved the trailing delimiter handling into Verification from the follow-up run:
I also attempted full |
|
This PR is strange in various ways and Blake expressed disinterest in this PR and its ticket. Perhaps "vibhor" in "vibhor-aggr" stands for something viber/vibe-coder and Blake and I are the only real people here. Maybe Blake is not "real" either I don't know anymore. |
Fixes #441.
pathToRegexp('/about/')currently appends the optional trailing delimiter after a source that already ends in/, so the generated matcher accepts/about//. This moves the optional trailing delimiter into each flattened alternative and skips it when that alternative already ends with the configured delimiter.Verification:
./node_modules/.bin/vitest run src/index.spec.ts -t '/test//'./node_modules/.bin/vitest run src/index.spec.tsnpm run buildnpm run sizegit diff --checkNote: I also attempted
npm test; it reached 477 passing Vitest tests but the local ReDoS helper binary requires GLIBC_2.32/GLIBC_2.34 while this host has glibc 2.28, so that command exits withrecheck-linux-x64EPIPE errors in this environment.