Commit 4cce3ed4 authored by Robert Knight's avatar Robert Knight

Modify unicode service to use String.prototype.normalize

unorm is a large library which also exposes its functionality as a
`String.prototype.normalize` polyfill.

Using the native method is a first step towards not loading unorm in
browsers that have Unicode normalization available natively.
parent 879968a0
'use strict';
const unorm = require('unorm');
if (typeof String.prototype.normalize !== 'function') {
require('unorm');
}
/**
* Unicode combining characters
......@@ -11,7 +13,7 @@ const COMBINING_MARKS = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u0
// @ngInject
function unicode() {
return {
normalize: str => unorm.nfkd(str),
normalize: str => str.normalize('NFKD'),
fold: str => str.replace(COMBINING_MARKS, ''),
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment