mirror of
https://github.com/zotero/zotero.git
synced 2026-10-02 02:11:33 +00:00
Match duplicate books by ISBN-10/13 equivalence (#6028)
--------- Co-authored-by: Dan Stillman <dstillman@zotero.org>
This commit is contained in:
parent
9086156a91
commit
e3da52bebc
2 changed files with 21 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue