Skip to content

Commit

Permalink
Refactored stripDiacritics file
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sakharov committed Dec 22, 2017
1 parent b35f8d0 commit 880a473
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/stripDiacritics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var map = [
const map = [
{ 'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g },
{ 'base':'AA','letters':/[\uA732]/g },
{ 'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g },
Expand Down Expand Up @@ -85,9 +85,11 @@ var map = [
{ 'base':'z', 'letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g },
];

export default function stripDiacritics (str) {
for (var i = 0; i < map.length; i++) {
const stripDiacritics = str => {
for (let i = 0; i < map.length; i++) {
str = str.replace(map[i].letters, map[i].base);
}
return str;
};

export default stripDiacritics;

0 comments on commit 880a473

Please sign in to comment.