bengourley / slugg

Make strings url safe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slugifying certain non-word characters (likely an edge case)

jayceekay opened this issue · comments

Hi. I like this module, but I have a question about an edge case. With the string "!@#!@!@" your module slugifys it into "", which I'm sure is intended, but your library doesn't offer a way for me to allow people to make these sort of titles yet still have it slugify to something.

There are a few ways to accomplish the above: either by enhancing/modifying the character map, enabling or disabling the stripping of slashes from the front and beginning of the string, implementing toNotStrip functionality. Also, given the above string it might also be desirable for it to slugify to something equal in character length, so maybe that could be an option as well. I thought I would open this to see what you thought before going off and forking.

Thanks for raising this as a concern. Personally I think I'm happy with the current behaviour. My primary use case for this module is to automatically create a url-part from an article title in a CMS. If the CMS user entered "!@#!@!@" as the title for their article, then the slug field would be not be populated. Since slug is a required field, validation would fail saying 'slug is required'.

If there is a good reason to add 'toNotStrip' functionality to the module then I will be glad to add it. However, I want to keep the module as small and simple as possible, so the reason should be compelling and applicable to a set of use cases.

Cheers

@jayceekay think you are searching for this (my!) module https://npmjs.org/package/speakingurl
think it works for your issue, check it out