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

Clarify that minimal escaping is done (#30) and describe edge cases #40

Merged
merged 2 commits into from
Jun 14, 2024

Conversation

slevithan
Copy link
Contributor

@slevithan slevithan commented Jun 11, 2024

There have been multiple requests to escape additional characters, so this makes it clearer that minimal escaping is done, per #30 (comment). It also gives a solution for more involved context-aware escaping that handles numerous edge cases, for situations when developers need to insert an escaped string at an arbitrary position in a regex.

Fixes #30

…edge cases

There have been multiple requests to escape additional characters, so this makes it clearer that minimal escaping is done (per sindresorhus#30 (comment)). It also gives a solution for more involved context-aware escaping that handles numerous edge cases, for situations when developers need to insert an escaped string at an arbitrary position in a regex.
@slevithan
Copy link
Contributor Author

If you would prefer that I take out the link to the regex library (which provides a solution for the numerous edge-case context issues when escaping, and is based on discussion amongst TC39 members about alternative approaches for regex escaping), I would be happy to do so. However, I think it's worth letting people know that such edge cases exist.

escape-string-regexp's lack of support for context-related issues is a reasonable tradeoff in favor of simplicity.

@sindresorhus sindresorhus merged commit 6fe67c0 into sindresorhus:main Jun 14, 2024
0 of 2 checks passed
@sindresorhus
Copy link
Owner

Nice work on the regex package 👍

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.

Forward slash is not escaped
2 participants