fix(_utils): move hyphens to start of character classes in parseGitURI regex#262
fix(_utils): move hyphens to start of character classes in parseGitURI regex#262terminalchai wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe regex patterns in the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes a regex where hyphens inside character classes [...] were in a position that could be interpreted as a range operator.
Problem
In src/_utils.ts, the parseGitURI regex had character classes with hyphens in non-literal positions:
\\ s
// ambiguous — '-' between chars can mean a range
/[\w.-]/
\\
While V8 currently treats this as a literal hyphen, it is technically undefined behaviour per the spec and triggers lint warnings. ECMA-262 requires hyphens to be first, last, or escaped to be unambiguously literal.
Fix
Move hyphens to the start of each character class so they are unambiguously literal:
\\ s
/[-\w.]/
\\
Tests
Added test cases in \ est/utils.test.ts\ covering repo references that contain hyphens, ensuring they parse correctly.
Summary by CodeRabbit