-
-
Save hantv15/279a2e79b9f067e6912bc7d2a889d3d4 to your computer and use it in GitHub Desktop.
Revisions
-
bluzky revised this gist
Jun 3, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ function stringToSlug(str) { // remove accents var from = "àáãảạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệđùúủũụưừứửữựòóỏõọôồốổỗộơờớởỡợìíỉĩịäëïîöüûñçýỳỹỵỷ", to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeduuuuuuuuuuuoooooooooooooooooiiiiiaeiiouuncyyyyy"; for (var i=0, l=from.length ; i < l ; i++) { str = str.replace(RegExp(from[i], "gi"), to[i]); } -
bluzky revised this gist
Nov 9, 2017 . No changes.There are no files selected for viewing
-
bluzky created this gist
Nov 9, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function stringToSlug(str) { // remove accents var from = "àáãảạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệđùúủũụưừứửữựòóỏõọôồốổỗộơờớởỡợìíỉĩịäëïîöüûñç", to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeduuuuuuuuuuuoooooooooooooooooiiiiiaeiiouunc"; for (var i=0, l=from.length ; i < l ; i++) { str = str.replace(RegExp(from[i], "gi"), to[i]); } str = str.toLowerCase() .trim() .replace(/[^a-z0-9\-]/g, '-') .replace(/-+/g, '-'); return str; }