Skip to content

Conversation

@etr
Copy link
Owner

@etr etr commented Jan 28, 2026

Summary

  • Fix bug where URLs exactly matching a registered regex pattern string incorrectly dispatch to that resource instead of returning 404
  • Only add URLs without regex patterns to the fast string lookup map by checking idx.get_url_pars().empty() before insertion
  • Enable the previously disabled test case in basic.cpp

Fixes #308

Test plan

  • regex_url_exact_match test passes with expected 404 response
  • All 12 tests pass (make check)

URLs that exactly match a registered regex pattern string were incorrectly
dispatching to that resource instead of returning 404. For example,
registering `/foo/{v|[a-z]}/bar` and then requesting the literal URL
`/foo/{v|[a-z]}/bar` returned 200 instead of 404.

The root cause was that URLs with regex patterns were being added to
`registered_resources_str` (fast string lookup map). When a request
matched the literal pattern text, it bypassed regex validation.

Fix: Only add URLs without regex patterns to the fast string lookup map
by checking `idx.get_url_pars().empty()` before insertion.
@etr etr merged commit bca2674 into master Jan 28, 2026
38 checks passed
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.

[BUG] URL's that exactly match a registried regex pattern dispatch to that registered resource

2 participants