From f973897d76deb37f601057ae0cdc2bcec7f9317c Mon Sep 17 00:00:00 2001 From: adam3smith Date: Mon, 1 Sep 2014 14:31:51 -0500 Subject: [PATCH 1/2] test for presence of author's firstName before using it --- chrome/content/zotero/xpcom/openurl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/content/zotero/xpcom/openurl.js b/chrome/content/zotero/xpcom/openurl.js index d28156275..8482dfd46 100644 --- a/chrome/content/zotero/xpcom/openurl.js +++ b/chrome/content/zotero/xpcom/openurl.js @@ -480,6 +480,7 @@ Zotero.OpenURL = new function() { // same last name, and the same first name up to a point), keep // the plain author, since it might have a middle initial if(item.creators[j].lastName == complexAu[i].lastName && + item.creators[j].firstName && (item.creators[j].firstName == complexAu[i].firstName == "" || (item.creators[j].firstName.length >= complexAu[i].firstName.length && item.creators[j].firstName.substr(0, complexAu[i].firstName.length) == complexAu[i].firstName))) { From 17c0f44e66c5c64b181c95e49095403a78b2eee4 Mon Sep 17 00:00:00 2001 From: adam3smith Date: Mon, 1 Sep 2014 19:25:10 -0500 Subject: [PATCH 2/2] fix indenting --- chrome/content/zotero/xpcom/openurl.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/xpcom/openurl.js b/chrome/content/zotero/xpcom/openurl.js index 8482dfd46..5a2c4d374 100644 --- a/chrome/content/zotero/xpcom/openurl.js +++ b/chrome/content/zotero/xpcom/openurl.js @@ -475,18 +475,18 @@ Zotero.OpenURL = new function() { var pushMe = true; var offset = complexAu[i].offset; delete complexAu[i].offset; - for(var j=0; j= complexAu[i].firstName.length && - item.creators[j].firstName.substr(0, complexAu[i].firstName.length) == complexAu[i].firstName))) { - pushMe = false; - break; - } + for (var j = 0; j < item.creators.length; j++) { + // if there's a plain author that is close to this author (the + // same last name, and the same first name up to a point), keep + // the plain author, since it might have a middle initial + if (item.creators[j].lastName == complexAu[i].lastName && + item.creators[j].firstName && + (item.creators[j].firstName == complexAu[i].firstName == "" || + (item.creators[j].firstName.length >= complexAu[i].firstName.length && + item.creators[j].firstName.substr(0, complexAu[i].firstName.length) == complexAu[i].firstName))) { + pushMe = false; + break; + } } // Splice in the complex creator at the correct location, // accounting for previous insertions