Skip to content

Commit 6e9d8cb

Browse files
committed
#106 improve whitespace handling in LexisNexis case numbers
1 parent c1b1698 commit 6e9d8cb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

serverless/lib/SearchParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const SearchParser = {
77
// Convert any Lexis Nexis formatted case numbers to standard format
88
// Example: 5902022CR 714844 => 22CR714844-590
99
const normalized = input.replace(
10-
/(?<county_code>\d{3})(?:19|20)(?<year>\d{2})(?<case_type>[A-Za-z]{2})?[ S]?(?<case_no>\d{6})/g,
10+
/(?<county_code>\d{3})(?:19|20)(?<year>\d{2})(?<case_type>[A-Za-z]{2})?(?:S|\s\n?)?(?<case_no>\d{6})/g,
1111
(_match, ...args) => {
1212
const groups = args[args.length - 1];
1313
const caseType = groups.case_type || 'CR';

serverless/lib/__tests__/searchParser.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ describe('SearchParser', () => {
2929
// Example: 5902022CR 714844 => 22CR714844-590
3030
expect(SearchParser.parseSearchInput('5902022CR 714844')).toEqual(['22CR714844-590']);
3131
expect(SearchParser.parseSearchInput('5902022CR714844')).toEqual(['22CR714844-590']);
32+
expect(SearchParser.parseSearchInput('5902022CR\r\n714844')).toEqual(['22CR714844-590']);
33+
expect(SearchParser.parseSearchInput('5902022CR\n714844')).toEqual(['22CR714844-590']);
34+
expect(SearchParser.parseSearchInput('5902022CR\t714844')).toEqual(['22CR714844-590']);
3235
expect(SearchParser.parseSearchInput('1232023CV 123456')).toEqual(['23CV123456-123']);
3336
expect(SearchParser.parseSearchInput('1232023CRS987654')).toEqual(['23CR987654-123']);
3437
expect(SearchParser.parseSearchInput('3302021S000986')).toEqual(['21CR000986-330']);
@@ -37,9 +40,12 @@ describe('SearchParser', () => {
3740
it('should handle multiple Lexis Nexis case numbers', () => {
3841
expect(
3942
SearchParser.parseSearchInput(
40-
'5902022CR 714844 5902022CR714844 3302021S000986 1232023CV 123456 1232023CRS987654'
43+
'5902022CR 714844 5902022CR714844 5902022CR\r\n714844 5902022CR\n714844 5902022CR\t714844 3302021S000986 1232023CV 123456 1232023CRS987654'
4144
)
4245
).toEqual([
46+
'22CR714844-590',
47+
'22CR714844-590',
48+
'22CR714844-590',
4349
'22CR714844-590',
4450
'22CR714844-590',
4551
'21CR000986-330',

0 commit comments

Comments
 (0)