Match duplicate books by ISBN-10/13 equivalence (#6028)

---------

Co-authored-by: Dan Stillman <dstillman@zotero.org>
This commit is contained in:
Jakob Nylin 2026-09-03 18:42:04 +02:00 • committed by GitHub
parent 9086156a91
commit e3da52bebc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -211,6 +211,8 @@ Zotero.Duplicates.prototype._findDuplicates = async function () {
let row = rows[i];
let newVal = Zotero.Utilities.cleanISBN('' + row.value);
if (!newVal) continue;
// Canonicalize to ISBN-13 so an ISBN-10 and its ISBN-13 equivalent match
newVal = Zotero.Utilities.toISBN13(newVal);
isbnCache[row.itemID] = newVal;
newRows.push({
itemID: row.itemID,

View file

@ -20,7 +20,25 @@ describe("Duplicate Items", function () {
after(function () {
win.close();
});
describe("ISBN matching", function () {
it("should match books with equivalent ISBN-10 and ISBN-13", async function () {
var item1 = await createDataObject('item', { itemType: 'book', title: 'Effective Java' });
item1.setField('ISBN', '0134685997');
await item1.saveTx();
var item2 = await createDataObject('item', { itemType: 'book', title: 'Effective Java, 3rd Edition' });
item2.setField('ISBN', '9780134685991');
await item2.saveTx();
var duplicates = new Zotero.Duplicates(Zotero.Libraries.userLibraryID);
await duplicates.getSearchObject();
assert.sameMembers(duplicates.getSetItemsByItemID(item1.id), [item1.id, item2.id]);
});
});
async function merge(itemID) {
var userLibraryID = Zotero.Libraries.userLibraryID;