Skip to content

feat!: replace regex route matching with URLPattern - #36

Merged
swiknaba merged 2 commits into
mainfrom
fix/deployment-url-pattern
May 3, 2026
Merged

feat!: replace regex route matching with URLPattern#36
swiknaba merged 2 commits into
mainfrom
fix/deployment-url-pattern

Conversation

@swiknaba

@swiknaba swiknaba commented May 3, 2026

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: Deployment route patterns now use URLPattern syntax instead of glob-style patterns.

Before: 'example.com/'
After: 'https://.example.com/'

This eliminates the ReDoS vulnerability from regex-based matching and pre-compiles URLPattern instances at router creation time for better per-request performance.

Key changes:

  • deployment-for-request.ts: replaced regex with URLPattern, added compileDeployments() for pre-compilation
  • cloudflare-router.ts: pre-compiles deployments at createRouter() time
  • with-auth.ts: accepts CompiledDeployment[] instead of reading from config
  • Updated all tests and README for new pattern syntax

BREAKING CHANGE: Deployment route patterns now use URLPattern syntax
instead of glob-style patterns.

Before: '*example.com/*'
After:  'https://*.example.com/*'

This eliminates the ReDoS vulnerability from regex-based matching and
pre-compiles URLPattern instances at router creation time for better
per-request performance.

Key changes:
- deployment-for-request.ts: replaced regex with URLPattern, added
  compileDeployments() for pre-compilation
- cloudflare-router.ts: pre-compiles deployments at createRouter() time
- with-auth.ts: accepts CompiledDeployment[] instead of reading from config
- Updated all tests and README for new pattern syntax
@swiknaba
swiknaba requested a review from a team as a code owner May 3, 2026 19:35
Resolved conflicts in deployment-for-request.ts, cloudflare-router.ts,
and with-auth.ts. Updated all tests from merged branches (colon
passwords, IP auth, mixed auth) to use URLPattern syntax and the new
4-arg withAuth signature.
@swiknaba
swiknaba merged commit abfb17d into main May 3, 2026
4 checks passed
@swiknaba
swiknaba deleted the fix/deployment-url-pattern branch May 3, 2026 20:07
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.

1 participant