Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix autocorrect range #44

Closed
wants to merge 2 commits into from
Closed

fix autocorrect range #44

wants to merge 2 commits into from

Conversation

josoriom
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7e27622) 88.32% compared to head (7bf03cf) 88.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #44      +/-   ##
==========================================
+ Coverage   88.32%   88.51%   +0.18%     
==========================================
  Files          39       40       +1     
  Lines         377      383       +6     
  Branches       95       95              
==========================================
+ Hits          333      339       +6     
  Misses         44       44              
Files Coverage Δ
src/parse/swissDrivingLicense.ts 63.63% <ø> (ø)
src/parse/swissDrivingLicenseFields.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

{ ...firstNameTemplate, line: 2, start: 0, end: 30 },
].map(createFieldParser);
export default function swissDrivingLicenseFields(lines: string[]) {
const names = lines[2].replace(/^<+|<+$/g, '').split('<<');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very risky as it only works if the line is formatted correctly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@targos It is acceptable to use "<<" as the delimiter between the first and last name?

Copy link
Member

@targos targos Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the parsing should be resilient to lines that don't follow the standard.

  • What about lines without any <<?
  • What about lines with multiple names separated by <<?

I would prefer not to fundamentally change the parser to accomodate an edge case related to autocorrect only.

Also, this pattern isn't specific to the Swiss driving license. Don't we need similar code changes for other MRZ formats?

@targos
Copy link
Member

targos commented Oct 28, 2023

Here I propose a fix that doesn't change how the parsing works: #45

@josoriom
Copy link
Member Author

This solution addresses the problem and enhances error handling flexibility. Thanks!

@josoriom josoriom closed this Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants