@@ -453,13 +453,16 @@ function getItemsForCN(cn, locationId) {
453
453
cn = letters + numbers + restOfCN ;
454
454
}
455
455
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, '*.' ) ;
463
466
464
467
const { folioUrl, tenantId, token} = getStoredCredentials ( ) ;
465
468
const baseUrl = `${ folioUrl } /inventory/items` ;
0 commit comments