From a5e6160169755f5991d556c02d1191ee2dfc3b1e Mon Sep 17 00:00:00 2001 From: Paul Beaudoin Date: Thu, 31 Oct 2024 10:08:16 -0400 Subject: [PATCH] Fix small bug with identifying nypl checkin items Fix small bug where items generated from holdings record checkin cards failed to be identiifed as NYPL items. This had no known impact on behavior, but betrayed the "isItemNyplOwned" function's promise --- lib/ownership_determination.js | 2 +- test/ownership_determination.test.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ownership_determination.js b/lib/ownership_determination.js index 0441eeeb..e778659c 100644 --- a/lib/ownership_determination.js +++ b/lib/ownership_determination.js @@ -1,5 +1,5 @@ // NYPL item ids start with an 'i' -const NYPL_ITEM_ID_PATTERN = /^i\d+/ +const NYPL_ITEM_ID_PATTERN = /^i/ const isItemNyplOwned = (item) => { return NYPL_ITEM_ID_PATTERN.test(item?.uri) diff --git a/test/ownership_determination.test.js b/test/ownership_determination.test.js index a5ec11c9..d84f1225 100644 --- a/test/ownership_determination.test.js +++ b/test/ownership_determination.test.js @@ -2,7 +2,12 @@ const isItemNyplOwned = require('../lib/ownership_determination').isItemNyplOwne describe('isItemNyplOwned', function () { it('will only return true for certain items', function () { - const fakeNyplItems = [{ uri: 'i10022734' }, { uri: 'i123489' }] + const fakeNyplItems = [ + { uri: 'i10022734' }, + { uri: 'i123489' }, + // An item generated from a checkin card in a holding has this form: + { uri: 'i-h1234-1' } + ] const fakeColumbiaItems = [{ uri: 'ci10022734' }, { uri: 'ci123489' }] const fakePrincetonItems = [{ uri: 'pi10022734' }, { uri: 'pi123489' }] const fakeNonsenseItems = [{ uri: 'jsaoisjosjiaosjio' }, { uri: 'hello-mother' }]