[PR #31790] refactor(web): replace string.match with RegExp.exec for better perfo…refactor(web): replace string.match with RegExp.exec for better performance (#25199) #33409

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

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

State: open
Merged: No


Summary

This PR refactors the usage of string.match() to RegExp.exec() in 10 core frontend files under the web/ directory, following the requirements of Issue #25199. The main goals are:

  1. Improve performance of regular expression matching (consistent with SonarQube rule S6594)
  2. Fix ESLint compliance issues (no-cond-assign, regexp/no-unused-capturing-group)
  3. Ensure full functional consistency with no regression or breaking changes

All related unit tests (format.ts/urlValidation.ts/var.ts) and TypeScript type checks have passed, confirming the change is safe and non-disruptive.

Screenshots

Before After
N/A (code refactoring without UI changes) N/A

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

Related Issue

Fixes #25199

**Original Pull Request:** https://github.com/langgenius/dify/pull/31790 **State:** open **Merged:** No --- ## Summary This PR refactors the usage of `string.match()` to `RegExp.exec()` in 10 core frontend files under the `web/` directory, following the requirements of Issue #25199. The main goals are: 1. Improve performance of regular expression matching (consistent with SonarQube rule S6594) 2. Fix ESLint compliance issues (no-cond-assign, regexp/no-unused-capturing-group) 3. Ensure full functional consistency with no regression or breaking changes All related unit tests (format.ts/urlValidation.ts/var.ts) and TypeScript type checks have passed, confirming the change is safe and non-disruptive. ## Screenshots | Before | After | |--------|-------| | N/A (code refactoring without UI changes) | N/A | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `make lint` and `make type-check` (backend) and `cd web && npx lint-staged` (frontend) to appease the lint gods ## Related Issue Fixes #25199
yindo added the pull-request label 2026-02-21 20:53:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33409