Skip to content

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