[PR #191] [MERGED] fix: matchConfigPattern incorrectly matches :param with literal suffix #378

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/191
Author: @jokull
Created: 2/28/2026
Status: Merged
Merged: 3/2/2026
Merged by: @southpolesteve

Base: mainHead: fix/config-pattern-param-suffix


📝 Commits (1)

  • 0238bd0 fix: matchConfigPattern incorrectly matches :param with literal suffix

📊 Changes

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

View changed files

📝 packages/vinext/src/config/config-matchers.ts (+5 -1)
📝 packages/vinext/src/index.ts (+2 -1)
📝 packages/vinext/src/server/app-dev-server.ts (+1 -1)
📝 tests/shims.test.ts (+24 -0)

📄 Description

Summary

  • Patterns like /:slug.md fell through to the simple segment matcher, which treated slug.md as the entire parameter name and matched any single-segment path (including /)
  • This caused rewrites like { source: "/:slug.md", destination: "/api/markdown/:slug" } to rewrite every page request, resulting in 404s on all routes
  • Added /:[\w-]+\./.test(pattern) to the condition that triggers the regex-based matcher, which already tokenizes :slug + . + md correctly

Test plan

  • Added unit tests for /:slug.md pattern via both index.ts and config/config-matchers.ts
  • All 18 existing matchConfigPattern tests pass (no regressions)
  • Verified with a real app: GET / returns 200 with HTML (was 404 before)

🤖 Generated with Claude Code


🔄 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/191 **Author:** [@jokull](https://github.com/jokull) **Created:** 2/28/2026 **Status:** ✅ Merged **Merged:** 3/2/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/config-pattern-param-suffix` --- ### 📝 Commits (1) - [`0238bd0`](https://github.com/cloudflare/vinext/commit/0238bd094dbb4a422860f570f54796416b130d34) fix: matchConfigPattern incorrectly matches :param with literal suffix ### 📊 Changes **4 files changed** (+32 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/config-matchers.ts` (+5 -1) 📝 `packages/vinext/src/index.ts` (+2 -1) 📝 `packages/vinext/src/server/app-dev-server.ts` (+1 -1) 📝 `tests/shims.test.ts` (+24 -0) </details> ### 📄 Description ## Summary - Patterns like `/:slug.md` fell through to the simple segment matcher, which treated `slug.md` as the entire parameter name and matched any single-segment path (including `/`) - This caused rewrites like `{ source: "/:slug.md", destination: "/api/markdown/:slug" }` to rewrite **every page request**, resulting in 404s on all routes - Added `/:[\w-]+\./.test(pattern)` to the condition that triggers the regex-based matcher, which already tokenizes `:slug` + `.` + `md` correctly ## Test plan - [x] Added unit tests for `/:slug.md` pattern via both `index.ts` and `config/config-matchers.ts` - [x] All 18 existing `matchConfigPattern` tests pass (no regressions) - [x] Verified with a real app: `GET /` returns 200 with HTML (was 404 before) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39: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#378
No description provided.