Skip to content

Remove trie deduplication#431

Merged
blakeembrey merged 4 commits intomasterfrom
be/remove-trie
Mar 30, 2026
Merged

Remove trie deduplication#431
blakeembrey merged 4 commits intomasterfrom
be/remove-trie

Conversation

@blakeembrey
Copy link
Copy Markdown
Member

Closes #430. The trie required a non-greedy match to work, and that results in an edge case with wildcards at the end of a path in end: false mode because it'd match up to the first match instead of all the way to the end. I hadn't anticipated the wildcard usage + end: false, then using the resulting path instead of originalPath in Express, in my refactoring.

@blakeembrey blakeembrey requested a review from a team March 30, 2026 22:35
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.74%. Comparing base (5bcd30b) to head (97c7249).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #431      +/-   ##
==========================================
- Coverage   99.75%   99.74%   -0.02%     
==========================================
  Files           1        1              
  Lines         416      389      -27     
  Branches      157      148       -9     
==========================================
- Hits          415      388      -27     
  Misses          1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

{
input: "/foo/bar.html/baz.html",
expected: {
path: "/foo/bar.html/baz.html",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is may be the clearest example of the issue and why it's impossible with the trie. The wildcard is expected to go over the first .:ext and use the last one, but with it being lazy it'd grab the first only.

And we can't just make it greedy with the trie because it breaks /*path{.:ext} where .:ext is optional, because then the greedy one just gobbles up everything and leaves .:ext always unmatched.

Unfortunately the trie was added to improve regex performance a little bit by deduplicating prefixes, so that optimization isn't possible without breaking this wildcard pattern in use.

@blakeembrey blakeembrey merged commit 6bc8e84 into master Mar 30, 2026
8 checks passed
@blakeembrey blakeembrey deleted the be/remove-trie branch March 30, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible regression from 8.4.0 changes regarding req.baseUrl in Express

1 participant