Skip to content

Commit

Permalink
Fix small bug with identifying nypl checkin items
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nonword committed Oct 31, 2024
1 parent 920798e commit a5e6160
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ownership_determination.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 6 additions & 1 deletion test/ownership_determination.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }]
Expand Down

0 comments on commit a5e6160

Please sign in to comment.