@@ -36,9 +36,11 @@ module.exports = {
36
36
let last_name ;
37
37
if ( serviceFromLineIndex >= 0 ) {
38
38
fullNameLine = rawText [ serviceFromLineIndex + 1 ] ;
39
- // first name & last name (dropping anything between first and last words)
40
- first_name = fullNameLine . split ( ' ' ) . slice ( 0 , 1 ) . join ( ' ' ) ;
41
- last_name = fullNameLine . split ( ' ' ) . slice ( - 1 ) . join ( ' ' ) ;
39
+ if ( ! fullNameLine . match ( / ^ Y O U R A C C O U N T S U M M A R Y ( .* ) $ / g) ) {
40
+ // first name & last name (dropping anything between first and last words)
41
+ first_name = fullNameLine . split ( ' ' ) . slice ( 0 , 1 ) . join ( ' ' ) ;
42
+ last_name = fullNameLine . split ( ' ' ) . slice ( - 1 ) . join ( ' ' ) ;
43
+ }
42
44
}
43
45
44
46
let last10Lines = rawText . slice ( - 10 ) ;
@@ -57,6 +59,13 @@ module.exports = {
57
59
// city, state, zip code
58
60
const lineWithCityStateZipCodeIndex = last10Lines . findIndex ( ( line ) => line . match ( / ^ ( [ A - Z a - z \s ] + ) ( [ A - Z ] { 2 } ) ( \d + - \d + ) $ / g) ) ;
59
61
if ( lineWithCityStateZipCodeIndex ) {
62
+ if ( ! first_name || ! last_name
63
+ || ! first_name . length || ! last_name . length
64
+ || first_name . match ( / \d + / g) || last_name . match ( / \d + / g) ) {
65
+ fullNameLine = last10Lines [ lineWithCityStateZipCodeIndex - 2 ] ;
66
+ first_name = fullNameLine . split ( ' ' ) . slice ( 0 , 1 ) . join ( ' ' ) ;
67
+ last_name = fullNameLine . split ( ' ' ) . slice ( - 1 ) . join ( ' ' ) ;
68
+ }
60
69
street_address_line_1 = last10Lines [ lineWithCityStateZipCodeIndex - 1 ] ;
61
70
street_address_line_2 = '' ;
62
71
cityStateZipCodeLine = last10Lines [ lineWithCityStateZipCodeIndex ] . split ( ' ' ) ;
0 commit comments