commit 7a5b1f7e32b619c2013a619196ecad762bd3d8a4
parent 83216d6125a8cd3f1800943f1a6646cf2c21ef46
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 7 Nov 2011 21:04:35 -0800
Merge pull request #6 from ajlyon/diacritic
Short-circuit removeDiacritics on alphanumeric and other basic input
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -671,6 +671,9 @@ Zotero.Utilities = {
* From http://lehelk.com/2011/05/06/script-to-remove-diacritics/
*/
"removeDiacritics": function (str, lowercaseOnly) {
+ // Short-circuit on the most basic input
+ if (/^[a-zA-Z0-9_-]*$/.test(str)) return str;
+
var map = this._diacriticsRemovalMap.lowercase;
for (var i=0, len=map.length; i<len; i++) {
str = str.replace(map[i].letters, map[i].base);
@@ -1296,4 +1299,4 @@ Zotero.Utilities = {
//this._cache[item.id] = cslItem;
return cslItem;
}
-}
-\ No newline at end of file
+}