mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #696] [MERGED] fix: anchor has/missing condition value regex for full-string matching #778
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#778
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/696
Author: @southpolesteve
Created: 3/27/2026
Status: ✅ Merged
Merged: 3/27/2026
Merged by: @southpolesteve
Base:
main← Head:fix/anchor-has-missing-condition-regex📝 Commits (1)
cc17d69fix: anchor has/missing condition value regex for full-string matching📊 Changes
2 files changed (+65 additions, -1 deletions)
View changed files
📝
packages/vinext/src/config/config-matchers.ts(+4 -1)📝
tests/shims.test.ts(+61 -0)📄 Description
Summary
Config rule
has/missingconditions now use anchored regex (^value$) for value matching, preventing partial substring matches.Details
Previously,
_cachedConditionRegex()compiled the condition value as an unanchored regex viasafeRegExp(value). This meant a condition likehas: [{ type: "cookie", key: "role", value: "admin" }]would match any cookie value containing "admin" as a substring (e.g., "not-admin", "admin-temp").The fix anchors the regex with
^and$, matching Next.js behavior (prepare-destination.tsusesnew RegExp(\^${hasItem.value}$`)`).Regex patterns in condition values continue to work correctly since anchoring just constrains them to match the full value.
Tests
Adds 4 tests:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.