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 leading and trailing replacement chars #115

Merged
merged 1 commit into from
May 8, 2021
Merged

Conversation

Trott
Copy link
Collaborator

@Trott Trott commented May 2, 2021

Fixes: #112
Closes: #110

@Trott
Copy link
Collaborator Author

Trott commented May 2, 2021

In addition to behaving the way most users likely expect the module to behave, this PR also fixes an edge case bug where certain replacement characters could cause syntax errors or exponential backtracking.

Without this PR:

slugify('foo bar', { replacement: '\\'})
Uncaught SyntaxError: Invalid regular expression: /[\s\]+/: Unterminated character class

With this PR:

slugify('foo bar', { replacement: '\\'})
'foo\\bar'

@Trott Trott merged commit b216bae into simov:master May 8, 2021
@Trott Trott deleted the trim branch May 8, 2021 05:08
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.

Allow to remove dash at the end of the slug
2 participants