Last active
December 29, 2015 10:26
-
-
Save olegp/af3126a2d5f28f14f388 to your computer and use it in GitHub Desktop.
JS code for generating SEO friendly URL fragments
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
function prettify(text) { | |
return text.toLowerCase() | |
.replace(/ä/g, 'a') | |
.replace(/ö/g, 'o') | |
.replace(/å/g, 'a') | |
.replace(/[^0-9a-z]+/g, '-') | |
.replace(/^-*(.*?)-*$/, '$1'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment