Comparing version 3.0.4 to 3.0.5
{ | ||
"name": "mrz", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Parse MRZ (Machine Readable Zone) from identity documents", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -35,2 +35,12 @@ 'use strict'; | ||
}); | ||
const optional1Details = result.details.find( | ||
(f) => f.field === 'optional1' | ||
); | ||
expect(optional1Details).toMatchObject({ | ||
value: '', | ||
line: 0, | ||
start: 15, | ||
end: 15 | ||
}); | ||
}); | ||
@@ -88,4 +98,4 @@ | ||
const MRZ = [ | ||
'I<UTOD23145890<1240<<<<<<<<<<<', | ||
'7408122F1204159UTO<<<<<<<<<<<0', | ||
'I<UTOD23145890<1240<XYZ<<<<<<<', | ||
'7408122F1204159UTO<<<<<<<<<<<8', | ||
'ERIKSSON<<ANNA<MARIA<<<<<<<<<<' | ||
@@ -107,3 +117,3 @@ ]; | ||
{ line: 0, start: 14, end: 15, raw: '<' }, | ||
{ line: 0, start: 15, end: 30, raw: '1240<<<<<<<<<<<' } | ||
{ line: 0, start: 15, end: 30, raw: '1240<XYZ<<<<<<<' } | ||
], | ||
@@ -110,0 +120,0 @@ line: 0, |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const parseOptional = require('../parsers/parseOptional'); | ||
const parseDocumentNumberOptional = require('../parsers/parseDocumentNumberOptional'); | ||
const { | ||
@@ -75,3 +76,15 @@ documentCodeTemplate, | ||
end: 30, | ||
parser: parseOptional | ||
related: [ | ||
{ | ||
line: 0, | ||
start: 5, | ||
end: 14 | ||
}, | ||
{ | ||
line: 0, | ||
start: 14, | ||
end: 15 | ||
} | ||
], | ||
parser: parseDocumentNumberOptional | ||
}, | ||
@@ -78,0 +91,0 @@ Object.assign({}, birthDateTemplate, { |
@@ -8,4 +8,5 @@ 'use strict'; | ||
if (checkDigit === '<' && optional) { | ||
optional = cleanText(optional); | ||
value = source + optional.substring(0, optional.length - 1); | ||
const firstFiller = optional.indexOf('<'); | ||
const tail = optional.substring(0, firstFiller - 1); | ||
value = source + tail; | ||
end = value.length + 1; | ||
@@ -12,0 +13,0 @@ } else { |
'use strict'; | ||
var check = require('./check'); | ||
const cleanText = require('./cleanText'); | ||
@@ -12,10 +11,11 @@ module.exports = function parseDocumentNumberCheckDigit( | ||
if (checkDigit === '<' && optional) { | ||
optional = cleanText(optional); | ||
source = `${source}<${optional.substring(0, optional.length - 1)}`; | ||
checkDigit = optional.charAt(optional.length - 1); | ||
const firstFiller = optional.indexOf('<'); | ||
const tail = optional.substring(0, firstFiller - 1); | ||
source = `${source}<${tail}`; | ||
checkDigit = optional.charAt(firstFiller - 1); | ||
check(source, checkDigit); | ||
return { | ||
value: checkDigit, | ||
start: optional.length, | ||
end: optional.length + 1 | ||
start: firstFiller, | ||
end: firstFiller + 1 | ||
}; | ||
@@ -22,0 +22,0 @@ } else { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51189
50
1839