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

Fix trim throwing regex error #251

Merged
merged 1 commit into from
Jun 26, 2023
Merged

Conversation

apstanisic
Copy link
Contributor

@apstanisic apstanisic commented Feb 7, 2023

Description

JS is throwing error if charsToTrim has some special value.
In this example, trim(" __-_ hello", "_- "), _- is treated as a range, but that range is invalid.
In this PR, every value that is not ascii char, number, or underscore (\W) is escaped.
There is maybe better way to do this, I'm not sure.
I'm not sure if this fixes all posibilities, especially with emojis and unicode, I'm not familiar enough.

Checklist

  • Changes are covered by tests if behavior has been changed or added
  • Tests have 100% coverage
  • If code changes were made, the version in package.json has been bumped (matching semver)
  • If code changes were made, the yarn build command has been run and to update the cdn directory
  • If code changes were made, the documentation (in the /docs directory) has been updated

Resolves

Resolves #250

@vercel
Copy link

vercel bot commented Feb 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
radash-docs ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 7, 2023 at 6:14PM (UTC)

@sodiray sodiray merged commit 9981032 into sodiray:master Jun 26, 2023
aleclarson referenced this pull request in radashi-org/radashi Jun 24, 2024
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.

trim throws on edge cases
2 participants