Skip to content

Commit 80a0c22

Browse files
committed
fixes azdl, fixes lint issues
1 parent a84d06e commit 80a0c22

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

lib/documentProcessor.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ it('Expect AZ diver license to be detected and processed', async () => {
3636

3737
expect(response.found).toBe(true);
3838
expect(response.documentType).toBe('Arizona\'s Driver License');
39-
expect(response.extracted.first_name).toBe('SAMPLE');
40-
expect(response.extracted.last_name).toBe('JELANI');
39+
expect(response.extracted.first_name).toBe('JELANI');
40+
expect(response.extracted.last_name).toBe('SAMPLE');
4141
expect(response.extracted.street_address_line_1).toBe('123 MAIN ST');
4242
expect(response.extracted.street_address_line_2).toBe('');
4343
expect(response.extracted.city).toBe('PHOENIX');

lib/documentTypes/arizonaDriverLicense.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@ module.exports = {
3030
}
3131

3232
// street address line 1 & 2
33-
const streetAddressLineIndex = rawText.findIndex((line) => line.match(/^8(.*)$/g));
33+
let streetAddressLineIndex = rawText.findIndex((line) => line.match(/^8(.*)$/g));
34+
const lineWithCityStateZipIndex = rawText.findIndex((line) => line.match(/^([A-Za-z\s]+,? )?[A-Z]{2} \d+-?\d+?$/g));
35+
if (streetAddressLineIndex < 0 && lineWithCityStateZipIndex >= 0) {
36+
streetAddressLineIndex = lineWithCityStateZipIndex - 1;
37+
}
3438
let street_address_line_1 = rawText[streetAddressLineIndex];
3539
let street_address_line_2 = rawText[streetAddressLineIndex + 1];
3640

3741
if (street_address_line_1 && street_address_line_1.substr(0, 2) === '8 ') {
3842
street_address_line_1 = street_address_line_1.replace('8 ', '');
3943
}
40-
4144
if (street_address_line_1 === '8') {
4245
street_address_line_1 = undefined;
4346
}
4447

4548
// city, state, zip code
46-
const lineWithCityStateZipIndex = rawText.findIndex((line) => line.match(/^([A-Za-z\s]+, )?[A-Z]{2} \d+\-?\d+?$/g));
4749
const lineWithCityStateZip = rawText[lineWithCityStateZipIndex];
48-
4950
if (!street_address_line_1 && lineWithCityStateZipIndex > 0) {
5051
street_address_line_1 = rawText[lineWithCityStateZipIndex - 1];
5152
}
@@ -55,7 +56,7 @@ module.exports = {
5556
street_address_line_2 = '';
5657
}
5758

58-
const matchedCityStateZip = /^([A-Za-z\s]+, )?([A-Z]{2}) (\d+\-?\d+?)$/g.exec(lineWithCityStateZip) || [];
59+
const matchedCityStateZip = /^([A-Za-z\s]+,? )?([A-Z]{2}) (\d+-?\d+?)$/g.exec(lineWithCityStateZip) || [];
5960
let [, city] = matchedCityStateZip;
6061
const [, , state, zip_code] = matchedCityStateZip;
6162
if (city) {

lib/documentTypes/southwestGasBill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = {
8686
&& line.match(/\d+/g)
8787
));
8888

89-
account_number = (/(.*) (\d+\-\d+\-\d+)/g.exec(account_number) || [])[2];
89+
[, , account_number] = (/(.*) (\d+-\d+-\d+)/g.exec(account_number) || []);
9090
}
9191

9292
return {

0 commit comments

Comments
 (0)