Skip to content

Commit 5174141

Browse files
committed
fix: improve call number wildcarding
1 parent 25ed1b2 commit 5174141

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Code.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,16 @@ function getItemsForCN(cn, locationId) {
453453
cn = letters + numbers + restOfCN;
454454
}
455455

456-
// Insert wildcards in front of every period.
457-
// GV199.F3 -> GV199*.F3
458-
// GV199.3 -> GV199*.3
459-
// GV199.92 .B38 A3 1994 -> GV199*.92*.B38 A3 1994
460-
// GV199.92.F39 .F39 2011 -> GV199*.92*.F39*.F39 2011
461-
// HB3717 1929.E37 2015 -> HB3717 1929*.E37 2015
462-
cn = cn.replace(/(\s*\.(?! ))/g, function($0, $1) { return '*.'; });
456+
// Insert wildcards in strategic places. This is an effort to account for the
457+
// following common errors seen in user inputs:
458+
// - missing a period (e.g., QC921.5 B9 versus QC921.5 .B9)
459+
// - adding or missing spaces (e.g., GV199 .F3 versus GV199.F3)
460+
// Keep in mind that it doesn't matter whether the user's input follows
461+
// correct LoC rules, because the entries in the database may have errors
462+
// too. What we want is to account for errors in either source.
463+
cn = cn.replace(/\s+\.(?! )/g, ' *');
464+
cn = cn.replace(/\s+(?=[a-z])/gi, ' *');
465+
cn = cn.replace(/(?<=[0-9])\.(?=[a-z])/gi, '*.');
463466

464467
const {folioUrl, tenantId, token} = getStoredCredentials();
465468
const baseUrl = `${folioUrl}/inventory/items`;

0 commit comments

Comments
 (0)