[PR #30441] refactor(web): use RegExp.exec instead of string.match #32820

Open
opened 2026-02-21 20:52:08 -05:00 by yindo · 0 comments
Owner

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

State: open
Merged: No


Summary

  • Replace string.match() with RegExp.exec() for better performance in cases where global flag is not needed
  • This follows the SonarQube rule S6594 recommendation

Changes

  • web/utils/error-parser.ts
  • web/utils/urlValidation.ts
  • web/app/components/tools/mcp/modal.tsx
  • web/app/components/base/ga/index.tsx
  • web/app/components/base/mermaid/index.tsx
  • web/app/components/base/mermaid/utils.ts (using .test() since only boolean check needed)
  • web/app/components/base/date-and-time-picker/utils/dayjs.ts
  • web/app/components/app/configuration/index.tsx
  • web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsx
  • web/app/components/base/features/new-feature-panel/annotation-reply/index.tsx

Test plan

  • All existing tests pass (pnpm test)
  • Type check passes (pnpm type-check:tsgo)
  • Lint check passes (pnpm lint:fix)

fixes #25199

**Original Pull Request:** https://github.com/langgenius/dify/pull/30441 **State:** open **Merged:** No --- ## Summary - Replace `string.match()` with `RegExp.exec()` for better performance in cases where global flag is not needed - This follows the [SonarQube rule S6594](https://next.sonarqube.com/sonarqube/coding_rules?open=javascript%3AS6594&rule_key=javascript%3AS6594) recommendation ## Changes - `web/utils/error-parser.ts` - `web/utils/urlValidation.ts` - `web/app/components/tools/mcp/modal.tsx` - `web/app/components/base/ga/index.tsx` - `web/app/components/base/mermaid/index.tsx` - `web/app/components/base/mermaid/utils.ts` (using `.test()` since only boolean check needed) - `web/app/components/base/date-and-time-picker/utils/dayjs.ts` - `web/app/components/app/configuration/index.tsx` - `web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsx` - `web/app/components/base/features/new-feature-panel/annotation-reply/index.tsx` ## Test plan - [x] All existing tests pass (`pnpm test`) - [x] Type check passes (`pnpm type-check:tsgo`) - [x] Lint check passes (`pnpm lint:fix`) fixes #25199
yindo added the pull-request label 2026-02-21 20:52:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32820