[PR #557] [MERGED] fix: preserve named has captures in config destinations #673

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

📋 Pull Request Information

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

Base: mainHead: fix/has-missing-capture-destinations


📝 Commits (2)

  • 47657c6 fix: preserve named has captures in config destinations
  • e668444 fix: align locale-static has capture precedence

📊 Changes

2 files changed (+155 additions, -53 deletions)

View changed files

📝 packages/vinext/src/config/config-matchers.ts (+90 -53)
📝 tests/shims.test.ts (+65 -0)

📄 Description

Summary

This preserves named capture groups from has conditions when vinext builds redirect and rewrite destinations.

Before this change, a rule could match successfully but still leave placeholders like :authorized unresolved in the destination. That diverged from documented Next.js behavior for config redirects and rewrites.

What Changed

  • changed config-matchers.ts so satisfied has conditions can return captured params instead of only a boolean
  • kept checkHasConditions() as the boolean wrapper for existing callers
  • merged has captures into the destination param bag for redirects and rewrites, matching Next.js's route-param-then-has-param merge order
  • added regression tests for the documented Next.js cases where (?<authorized>yes|true) is reused in redirect and rewrite destinations

Why It Matters

Redirects and rewrites that depend on captured header, cookie, query, or host values now produce the right destination instead of silently shipping unresolved placeholders.

Risks Or Limits

  • this change is intentionally narrow: missing conditions still act only as gates and do not contribute params
  • if a has capture name collides with a path param, the has capture wins, which matches Next.js's current merge order

Verification

  • vp test run tests/shims.test.ts
  • vp run typecheck

🔄 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/557 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/16/2026 **Status:** ✅ Merged **Merged:** 3/16/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/has-missing-capture-destinations` --- ### 📝 Commits (2) - [`47657c6`](https://github.com/cloudflare/vinext/commit/47657c62cae3c974763cc2a7c2d4db21827ad67d) fix: preserve named has captures in config destinations - [`e668444`](https://github.com/cloudflare/vinext/commit/e6684440cfea91929aa3717a91976f2ed5464f8b) fix: align locale-static has capture precedence ### 📊 Changes **2 files changed** (+155 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/config/config-matchers.ts` (+90 -53) 📝 `tests/shims.test.ts` (+65 -0) </details> ### 📄 Description ## Summary This preserves named capture groups from `has` conditions when vinext builds redirect and rewrite destinations. Before this change, a rule could match successfully but still leave placeholders like `:authorized` unresolved in the destination. That diverged from documented Next.js behavior for config redirects and rewrites. ## What Changed - changed `config-matchers.ts` so satisfied `has` conditions can return captured params instead of only a boolean - kept `checkHasConditions()` as the boolean wrapper for existing callers - merged `has` captures into the destination param bag for redirects and rewrites, matching Next.js's route-param-then-has-param merge order - added regression tests for the documented Next.js cases where `(?<authorized>yes|true)` is reused in redirect and rewrite destinations ## Why It Matters Redirects and rewrites that depend on captured header, cookie, query, or host values now produce the right destination instead of silently shipping unresolved placeholders. ## Risks Or Limits - this change is intentionally narrow: `missing` conditions still act only as gates and do not contribute params - if a `has` capture name collides with a path param, the `has` capture wins, which matches Next.js's current merge order ## Verification - `vp test run tests/shims.test.ts` - `vp run typecheck` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:09:28 +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#673
No description provided.