[PR #32386] refactor(web): replace String.match() with RegExp.exec() for non-global regex #33706

Closed
opened 2026-02-21 20:53:45 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/32386

State: closed
Merged: Yes


Summary

  • Replace string.match(regex) with regex.exec(string) across 18 files (~22 occurrences) per SonarQube rule S6594
  • When String#match is called without the global flag, it internally delegates to RegExp#exec, so calling exec() directly is more explicit and avoids the indirection
  • All .match() calls using global (g) flag regexes are intentionally left unchanged as they have different return semantics (returning all matches)

Closes #25199

Test plan

  • Run pnpm lint — no new lint errors
  • Run pnpm type-check:tsgo — no type errors
  • Run pnpm test — all existing tests pass
  • Verify skipped files still use .match() with global regex (e.g., block-input/index.tsx:16, mermaid/index.tsx:251)
**Original Pull Request:** https://github.com/langgenius/dify/pull/32386 **State:** closed **Merged:** Yes --- ## Summary - Replace `string.match(regex)` with `regex.exec(string)` across 18 files (~22 occurrences) per SonarQube rule S6594 - When `String#match` is called without the global flag, it internally delegates to `RegExp#exec`, so calling `exec()` directly is more explicit and avoids the indirection - All `.match()` calls using global (`g`) flag regexes are intentionally left unchanged as they have different return semantics (returning all matches) Closes #25199 ## Test plan - [ ] Run `pnpm lint` — no new lint errors - [ ] Run `pnpm type-check:tsgo` — no type errors - [ ] Run `pnpm test` — all existing tests pass - [ ] Verify skipped files still use `.match()` with global regex (e.g., `block-input/index.tsx:16`, `mermaid/index.tsx:251`)
yindo added the pull-request label 2026-02-21 20:53:45 -05:00
yindo closed this issue 2026-02-21 20:53:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33706