Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the regularization term #287

Closed
wants to merge 1 commit into from
Closed

Conversation

ShiyuBanzhou
Copy link

To resolve this #286 issue, it is recommended to replace the original code containing the inefficient regular expression with the following optimized version:

return url.replace(/^[\u0000-\u001F\u0020]+$/ug, "");

image-1
This alternative simplifies the regular expression by removing the redundant | (OR) operator, effectively resolving the inefficient backtracking behavior. This optimization prevents potential performance degradation when handling specific inputs, ensuring more efficient processing.

@domenic
Copy link
Member

domenic commented Jan 29, 2025

As you can see from the failing tests, the regexp you propose is not identical. Please add a new comment if you are able to fix it to pass the tests.

@domenic domenic closed this Jan 29, 2025
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