Ignore trailing period in domain for Quick Copy
From @aurimasv
This commit is contained in:
parent
899e33c993
commit
f07fe7184d
2 changed files with 6 additions and 1 deletions
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue