From e5e242db9980553f111c70a6872923a5363826d3 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Sun, 1 Apr 2012 23:38:50 -0500 Subject: [PATCH] Fix typo with nbsp. Fix dash handling --- chrome/content/zotero/xpcom/utilities.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index cdd19e0520..d94c55eb3e 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -144,14 +144,15 @@ Zotero.Utilities = { '\u0400-\u042f'; //cyrilic var allCapsRe = new RegExp('^[' + allCaps + ']+$'); + var initialRe = new RegExp('^-?[' + allCaps + ']$'); if(typeof(author) != "string") { throw "cleanAuthor: author must be a string"; } - author = author.replace(/^[\s\00A0\.\,\/\[\]\:]+/, '') - .replace(/[\s\00A0\.\,\/\[\]\:]+$/, '') - .replace(/[\s\00A0]+/, ' '); + author = author.replace(/^[\s\u00A0\.\,\/\[\]\:]+/, '') + .replace(/[\s\u00A0\.\,\/\[\]\:]+$/, '') + .replace(/[\s\u00A0]+/, ' '); if(useComma) { // Add spaces between periods @@ -187,14 +188,14 @@ Zotero.Utilities = { .replace(/[\s\,]+$/,'') //remove spaces surronding any dashes .replace(/\s*([\u002D\u00AD\u2010-\u2015\u2212\u2E3A\u2E3B])\s*/,'-') - .split(/[\s\.]+/); + .split(/(?:[\s\.]+|(?=-))/); var newFirstName = ''; for(var i=0, n=names.length; i