www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f07fe7184de1cc21a18cf0f9395e63ebd2b03421
parent 899e33c9935766e8c0e13888bcba79042ff29239
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri,  3 Jul 2015 23:46:39 -0400

Ignore trailing period in domain for Quick Copy

From @aurimasv

Diffstat:
Mchrome/content/zotero/xpcom/quickCopy.js | 3++-
Mtest/tests/quickCopyTest.js | 4++++
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 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 @@ -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); })