diff --git a/chrome/content/zotero/xpcom/quickCopy.js b/chrome/content/zotero/xpcom/quickCopy.js index a87768a1a2..9a7f8bc921 100644 --- a/chrome/content/zotero/xpcom/quickCopy.js +++ b/chrome/content/zotero/xpcom/quickCopy.js @@ -123,7 +123,8 @@ Zotero.QuickCopy = new function() { var sql = "SELECT key AS domainPath, value AS format FROM settings " + "WHERE setting='quickCopySite' AND (key LIKE ? OR key LIKE ?)"; - var urlDomain = urlHostPort.match(/(?:[^\.]+\.)?[^\.]+$/); + // Match last one or two sections of domain, not counting trailing period + var urlDomain = urlHostPort.match(/(?:[^.]+\.)?[^.]+(?=\.?$)/); // Hopefully can't happen, but until we're sure if (!urlDomain) { Zotero.logError("Quick Copy host '" + urlHostPort + "' not matched"); diff --git a/test/tests/quickCopyTest.js b/test/tests/quickCopyTest.js index d9d432a96b..44941b70b3 100644 --- a/test/tests/quickCopyTest.js +++ b/test/tests/quickCopyTest.js @@ -21,6 +21,10 @@ describe("Zotero.QuickCopy", function() { assert.deepEqual(Zotero.QuickCopy.getFormatFromURL('http://foo/'), quickCopyPref); }) + it("should handle a domain with a trailing period", function () { + assert.deepEqual(Zotero.QuickCopy.getFormatFromURL('http://foo.com.'), quickCopyPref); + }) + it("should handle an about: URL", function () { assert.deepEqual(Zotero.QuickCopy.getFormatFromURL('about:blank'), quickCopyPref); })