[PR #368] [MERGED] fix: enforce segment boundary in catch-all pattern matching #516

Closed
opened 2026-05-06 13:08:30 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/368
Author: @NathanDrake2406
Created: 3/9/2026
Status: Merged
Merged: 3/9/2026
Merged by: @james-elicx

Base: mainHead: fix/catch-all-prefix-overmatch


📝 Commits (2)

  • e1fc9f0 fix: enforce segment boundary in catch-all pattern matching
  • cc7f1fa test: regression tests for catch-all prefix segment boundary overmatch

📊 Changes

3 files changed (+46 additions, -4 deletions)

View changed files

📝 packages/vinext/src/config/config-matchers.ts (+5 -2)
📝 packages/vinext/src/index.ts (+5 -2)
📝 tests/shims.test.ts (+36 -0)

📄 Description

Summary

  • matchConfigPattern('/foobar', '/foo/:path*') incorrectly returned { path: 'bar' } because the startsWith('/foo') check doesn't enforce a / segment boundary after the prefix
  • Added a character check after the prefix match to reject paths like /foobar that share a prefix but aren't actual sub-paths
  • Fixed in both config-matchers.ts and the duplicated copy in index.ts

Test plan

  • matchConfigPattern('/foobar', '/foo/:path*')null
  • matchConfigPattern('/foo/bar', '/foo/:path*'){ path: 'bar' }
  • matchConfigPattern('/foo', '/foo/:path*'){ path: '' }
  • matchConfigPattern('/foobar', '/foo/:path+')null

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/368 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/9/2026 **Status:** ✅ Merged **Merged:** 3/9/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/catch-all-prefix-overmatch` --- ### 📝 Commits (2) - [`e1fc9f0`](https://github.com/cloudflare/vinext/commit/e1fc9f05c8d4deb6929d773a65a2a6dbd3e8e20a) fix: enforce segment boundary in catch-all pattern matching - [`cc7f1fa`](https://github.com/cloudflare/vinext/commit/cc7f1fa1ca89c496e0b24349e2147d7831c6b92f) test: regression tests for catch-all prefix segment boundary overmatch ### 📊 Changes **3 files changed** (+46 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/config-matchers.ts` (+5 -2) 📝 `packages/vinext/src/index.ts` (+5 -2) 📝 `tests/shims.test.ts` (+36 -0) </details> ### 📄 Description ## Summary - `matchConfigPattern('/foobar', '/foo/:path*')` incorrectly returned `{ path: 'bar' }` because the `startsWith('/foo')` check doesn't enforce a `/` segment boundary after the prefix - Added a character check after the prefix match to reject paths like `/foobar` that share a prefix but aren't actual sub-paths - Fixed in both `config-matchers.ts` and the duplicated copy in `index.ts` ## Test plan - [x] `matchConfigPattern('/foobar', '/foo/:path*')` → `null` - [x] `matchConfigPattern('/foo/bar', '/foo/:path*')` → `{ path: 'bar' }` - [x] `matchConfigPattern('/foo', '/foo/:path*')` → `{ path: '' }` - [x] `matchConfigPattern('/foobar', '/foo/:path+')` → `null` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:30 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#516
No description provided.