Skip to content

Commit

Permalink
Refactor - auto update credential provider script (#22922)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] authored Nov 6, 2024
1 parent 71d03b3 commit f06d2be
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,38 @@ export const FormAutofillHeuristics = {
fields[0].reason != "autocomplete" &&
["address-line2", "address-line3"].includes(fields[0].fieldName)
) {
scanner.updateFieldName(fieldIndicies[0], "address-line1");
// If an earlier address field was already found, ignore any
// address-related fields from the OTHER_ADDRESS_FIELDS
// list since those can appear in-between the address-level1
// and additional address info fields. If no address field
// exists, update the field to be address-line1.
const OTHER_ADDRESS_FIELDS = [
"address-level1",
"address-level2",
"postal-code",
"organization",
];
let canUpdate = true;

for (let idx = scanner.parsingIndex - 1; idx >= 0; idx--) {
const detail = scanner.getFieldDetailByIndex(idx);
if (
detail?.fieldName == "street-address" ||
detail?.fieldName == "address-line1" ||
detail?.fieldName == "address-housenumber"
) {
canUpdate = false;
break;
}

if (!OTHER_ADDRESS_FIELDS.includes(detail?.fieldName)) {
break;
}
}

if (canUpdate) {
scanner.updateFieldName(fieldIndicies[0], "address-line1");
}
}
break;
case 2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export const HeuristicsRegExp = {
"|^시[·・]?도", // ko-KR

"address-housenumber":
"housenumber|hausnummer|haus",
"housenumber|hausnummer|haus|house[a-z\-]*n(r|o)",

"postal-code":
"zip|postal|post.*code|pcode" +
Expand Down

0 comments on commit f06d2be

Please sign in to comment.