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

double dash bug #6

Open
ndimatteo opened this issue Oct 15, 2013 · 5 comments
Open

double dash bug #6

ndimatteo opened this issue Oct 15, 2013 · 5 comments

Comments

@ndimatteo
Copy link

Unfortunately when unicode characters are removed, there will be multiple spaces adjacent to one another that are then converted to dashes, leading to multiple, adjacent dashes. For example:

'Links & Resources' -> 'links--resources'

There should be a check for multiple spaces and reduce to just one.

@niftylettuce
Copy link

I think the bug here is that & character is not converted to and, but I will patch this.

@niftylettuce
Copy link

@ndimatteo you can close this issue and use https://github.com/dodo/node-slug/blob/master/src/slug.coffee#L71 which converts & to and.

@ndimatteo
Copy link
Author

Well, it looks like it removes special characters, which I'm fine with, it's putting a double dash because once the special char is removed the space before it and after it are now right next to each other and each are converted to dashes. I was just thinking that after anything is removed that it should run another check for more than one space adjacent to one another and reduce, so that when it converts to dashes it's only one.

I'm open to other suggestions though.

@Aaronontheweb
Copy link
Owner

@niftylettuce @ndimatteo I'll see about patching this soon - I'm using node-slugs in a new project and it needs some updates.

@bob6664569
Copy link

Just add

.replace(/--+/, '-')

after the last one in the replacement chain

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

No branches or pull requests

4 participants