diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 83832baf31..c2cf421c0d 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -1983,11 +1983,9 @@ Zotero.Items = function() { '', // Any punctuation at the beginning of the string '^\\p{P}+', - // Initial, opening, closing, final, other punctuation: - // pretty much anything that isn't a connector/dash. - // Positively matching each of these classes compiles to a cleaner - // native RegExp than XRegExp('[^\\P{P}\\p{Pd}]') - '[\\p{Pi}\\p{Ps}\\p{Pe}\\p{Pf}\\p{Po}]' + // Initial, opening, closing, final, and "other" punctuation that isn't + // followed by a digit. Doesn't match connectors or dashes. + '[\\p{Pi}\\p{Ps}\\p{Pe}\\p{Pf}\\p{Po}](?!\\d)' ].map(re => Zotero.Utilities.XRegExp(re, 'g')); diff --git a/test/tests/itemsTest.js b/test/tests/itemsTest.js index c2f9f4a04e..4ea5cf2f60 100644 --- a/test/tests/itemsTest.js +++ b/test/tests/itemsTest.js @@ -1163,5 +1163,17 @@ describe("Zotero.Items", function () { assert.equal(Zotero.Items.getSortTitle(input), expected); } }); + + it("should not strip any punctuation before a digit", function () { + let tests = [ + ['1.5', '1.5'], + ['abc .5', 'abc .5'], + ['abc 5.', 'abc 5'] + ]; + + for (let [input, expected] of tests) { + assert.equal(Zotero.Items.getSortTitle(input), expected); + } + }); }); });