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

Fixed two bugs with handling of the replacement character + tests #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raydog
Copy link

@raydog raydog commented May 3, 2016

Fixes two bugs I found while reading the source code:

  1. The regexp that replaces multiple spaces/separators accidentally hard-codes '-' in the regexp, meaning that this behavior won't work with custom separators.
  2. The code that replaces trailing separators doesn't use the regexp constructor, so it will only remove a trailing separator when followed by a '$' character, which is strange. This fixes that behavior, as well as extends it to cover leading separators as well.

This is similar to PR #55, except that this code escapes the separator, so it should still work when the replacement character is a regexp character.

@lillem4n
Copy link

lillem4n commented Jan 5, 2018

I added your test for multiple leading and trailing separators in my fork here: larvit@e1500dd

But since I rewrote the base code quite a bit for a lot of reasons, I made it an option to remove multiple whitespaces. That collides with hard coding something that removes multiple instances of the replace character as well... I have no pretty solution for this, do you?

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