Skip to content

fix: remove grammar-level regex literal parsing to fix path ambiguity#620

Merged
philmillman merged 4 commits intomainfrom
fix/regex-literal-path-ambiguity
Apr 15, 2026
Merged

fix: remove grammar-level regex literal parsing to fix path ambiguity#620
philmillman merged 4 commits intomainfrom
fix/regex-literal-path-ambiguity

Conversation

@theoephraim
Copy link
Copy Markdown
Member

Summary

  • Removed RegexLiteral rule from the PEG grammar and ParsedEnvSpecRegexLiteral class — paths like /folder/foo/bar were incorrectly parsed as regex patterns
  • Regex-like strings (/pattern/flags) are now detected at runtime by specific consumers: remap() match values and the matches type option on string/url data types
  • Added parseRegexLikeString() helper that detects unquoted strings matching /pattern/flags syntax
  • Updated docs to explain the regex-like string behavior and the quoting escape hatch for literal path strings

Test plan

  • Parser tests: regex-like strings and paths (quoted/unquoted) parse as plain strings
  • Resolver tests: paths in remap() are exact-matched, regex-like strings still work as patterns
  • Data type tests: matches option works with regex-like strings and quoted patterns
  • All 206 parser tests + 394 varlock tests pass
  • Lint clean

🤖 Generated with Claude Code

Paths like `/folder/foo/bar` were incorrectly parsed as regex literals.
Moved regex detection from the PEG grammar to runtime consumers (remap()
and matches type option) which check for regex-like unquoted strings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: fd4b0f1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@env-spec/parser Patch
varlock
env-spec-language Patch
@varlock/astro-integration Major
@varlock/cloudflare-integration Major
@varlock/expo-integration Major
@varlock/nextjs-integration Major
@varlock/vite-integration Major
@varlock/1password-plugin Major
@varlock/aws-secrets-plugin Major
@varlock/azure-key-vault-plugin Major
@varlock/bitwarden-plugin Major
@varlock/dashlane-plugin Major
@varlock/google-secret-manager-plugin Major
@varlock/hashicorp-vault-plugin Major
@varlock/infisical-plugin Major
@varlock/keepass-plugin Major
@varlock/pass-plugin Major
@varlock/passbolt-plugin Major
@varlock/proton-pass-plugin Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@env-spec/parser@620
npm i https://pkg.pr.new/varlock@620

commit: fd4b0f1

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
varlock-website 4820c56 Commit Preview URL

Branch Preview URL
Apr 15 2026, 06:10 PM

Remove regex literal detection from isDynamicValue() and update
regex() deprecation text in intellisense catalog.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
theoephraim and others added 2 commits April 15, 2026 11:15
Use quoted string patterns for URL matching tests instead of
heavily-escaped unquoted regex syntax. Keep some unquoted /pattern/
tests for coverage of both styles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@theoephraim theoephraim requested a review from philmillman April 15, 2026 18:24
@philmillman philmillman merged commit 0f3ca3b into main Apr 15, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants