Last active
November 20, 2019 13:35
-
-
Save ahultgren/5284223 to your computer and use it in GitHub Desktop.
A little helper to remove so called diacritics from latin characters (eg convert international characters to url-friendly ones). Please tell me if you find some missing characters or a way to make this more efficient.
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
"use strict"; | |
var accents = 'àáäâæåèéëêęìíïîòóöôøœōõùúüûūýçñ', | |
normals = 'aaaaaaeeeeeiiiioooooooouuuuuycn', | |
diacriticsRegexp = new RegExp('[' + accents + ']', 'ig'); | |
module.exports = exports = function undiacritics (string) { | |
return string.replace(diacriticsRegexp, function(s){ | |
return normals[accents.indexOf(s)]; | |
}); | |
}; | |
exports.addChars = function (accent, normal) { | |
accents += accent; | |
normals += normals; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a lot of variety by riwaj men's wear that you like to wear new dress design