Skip to content

Commit dd48456

Browse files
committed
fixes AZDL extraction
1 parent 6f4708b commit dd48456

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/documentTypes/arizonaDriverLicense.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ module.exports = {
1717

1818
extractor: (keyValues, rawText) => {
1919
// first name
20-
let first_name = rawText.find((line) => line.match(/^1 (.*)$/g));
21-
if (first_name && first_name.substr(0, 2) === '1 ') {
22-
first_name = first_name.replace('1 ', '');
20+
let first_name = rawText.find((line) => line.match(/^2 (.*)$/g));
21+
if (first_name && first_name.substr(0, 2) === '2 ') {
22+
first_name = first_name.replace('2 ', '');
2323
}
24+
first_name = first_name.split(' ').shift();
2425

2526
// last name
26-
let last_name = rawText.find((line) => line.match(/^2 (.*)$/g));
27-
if (last_name && last_name.substr(0, 2) === '2 ') {
28-
last_name = last_name.replace('2 ', '');
27+
let last_name = rawText.find((line) => line.match(/^1 (.*)$/g));
28+
if (last_name && last_name.substr(0, 2) === '1 ') {
29+
last_name = last_name.replace('1 ', '');
2930
}
3031

3132
// street address line 1 & 2
@@ -42,7 +43,7 @@ module.exports = {
4243
}
4344

4445
// city, state, zip code
45-
const lineWithCityStateZipIndex = rawText.findIndex((line) => line.match(/^([A-Za-z\s]+, )?[A-Z]{2} \d+$/g));
46+
const lineWithCityStateZipIndex = rawText.findIndex((line) => line.match(/^([A-Za-z\s]+, )?[A-Z]{2} \d+\-?\d+?$/g));
4647
const lineWithCityStateZip = rawText[lineWithCityStateZipIndex];
4748

4849
if (!street_address_line_1 && lineWithCityStateZipIndex > 0) {
@@ -54,7 +55,7 @@ module.exports = {
5455
street_address_line_2 = '';
5556
}
5657

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

0 commit comments

Comments
 (0)