-
-
Save dlindenkreuz/a439ec4b939f0561d6d9 to your computer and use it in GitHub Desktop.
Shopify handleize function in JavaScript
This file contains 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
// one-liner version | |
// retains latin-1 supplement chars as well as latin extended-a and latin extended-b | |
Shopify.handleize = function (str) { | |
return str.toLowerCase().replace(/[^\w\u00C0-\u024f]+/g, "-").replace(/^-+|-+$/g, ""); | |
}; |
'
should be removed instead of replacing with-
This.
Also problem with accents
return str.toLowerCase().replace(''', '').replace(/[^\w\u00C0-\u024f]+/g, "-").replace(/^-+|-+$/g, "").normalize("NFD").replace(/[\u0300-\u036f]/g, "")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'
should be removed instead of replacing with-