Created
May 2, 2014 09:23
-
-
Save lerouxb/97d678a5a9de16149844 to your computer and use it in GitHub Desktop.
Turn names/titles/whatever into url/filename-friendly bits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| slugify = (title) -> | |
| title | |
| .toLowerCase() | |
| .replace(/\ /g, '-') # spaces to dashes | |
| .replace(/[^\w-]+/g, '') # remove anything that's not ascii A-Za-z0-9 | |
| .replace(/[-]+/g, '-') # remove consecutive dashes |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python has unicodedata.normalize() which is really handy for converting accented characters into ascii characters which is arguably better than just stripping them. Could be nice to try and do that for JavaScript too.
https://docs.python.org/2/library/unicodedata.html