Skip to content

fix(planning): remove unnecessary global flag from module-level regex#1712

Merged
Yeachan-Heo merged 1 commit intoYeachan-Heo:devfrom
lifrary:fix/remove-unnecessary-global-flag-artifacts-regex
Mar 17, 2026
Merged

fix(planning): remove unnecessary global flag from module-level regex#1712
Yeachan-Heo merged 1 commit intoYeachan-Heo:devfrom
lifrary:fix/remove-unnecessary-global-flag-artifacts-regex

Conversation

@lifrary
Copy link
Contributor

@lifrary lifrary commented Mar 17, 2026

Problem

TEAM_LAUNCH_RE and RALPH_LAUNCH_RE in src/planning/artifacts.ts are declared at module level with the /g (global) flag, but each regex is only used with a single exec() call per function invocation.

The /g flag causes RegExp objects to maintain internal lastIndex state between calls. The current code works around this with manual lastIndex = 0 resets before each exec(), but this pattern is fragile — if the regex is ever reused elsewhere without the reset, it will silently fail to match.

// Before: /g flag requires manual lastIndex reset
TEAM_LAUNCH_RE.lastIndex = 0;
const match = TEAM_LAUNCH_RE.exec(content);

Fix

  • Remove /g flag from both TEAM_LAUNCH_RE and RALPH_LAUNCH_RE
  • Remove the now-unnecessary lastIndex = 0 reset lines
// After: no /g flag, no lastIndex state to manage
const match = TEAM_LAUNCH_RE.exec(content);

Verification

  • All 17 existing tests in src/planning/__tests__/artifacts.test.ts pass
  • No other files reference these regex constants (confirmed via codebase grep)
  • Behavioral change: none — exec() without /g returns the same first match

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Yeachan-Heo Yeachan-Heo merged commit 83fd4f9 into Yeachan-Heo:dev Mar 17, 2026
7 checks passed
@lifrary lifrary deleted the fix/remove-unnecessary-global-flag-artifacts-regex branch March 17, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants