diff --git a/test/tests/utilitiesTest.js b/test/tests/utilitiesTest.js index fa4e00a..2cc21c7 100644 --- a/test/tests/utilitiesTest.js +++ b/test/tests/utilitiesTest.js @@ -99,7 +99,7 @@ describe("Zotero.Utilities", function() { assert.equal(cleanDOI(`Foo bar ${encodedUri}. Foo bar`), expected); }); - it("should parse a DOI with url encoded params", function () { + it("should parse a DOI URL with encoded characters", function () { const encodedUri = "https://doi.org/10.1002/1096-9128(200005)12:6%3C375::AID-CPE480%3E3.0.CO;2-M"; const expected = "10.1002/1096-9128(200005)12:6<375::AID-CPE480>3.0.CO;2-M"; assert.equal(cleanDOI(`Foo bar ${encodedUri}. Foo bar`), expected); diff --git a/utilities.js b/utilities.js index 21f36ec..14ea081 100644 --- a/utilities.js +++ b/utilities.js @@ -499,11 +499,11 @@ var Utilities = { var result = doi[0]; // Check if the DOI ends with a bracket - const trailingBracket = result.slice(-1); + var trailingBracket = result.slice(-1); if ([']', ')', '}'].includes(trailingBracket)) { // Check the portion of the string before the matched DOI for an unclosed bracket - const beforeDOI = x.slice(0, doi.index); - const openingBracket = { + let beforeDOI = x.slice(0, doi.index); + let openingBracket = { ']': '[', ')': '(', '}': '{'