From d408f971c4363e8d2e0fe837a35a17619cd0510a Mon Sep 17 00:00:00 2001 From: Emanuele Feliziani Date: Thu, 10 Mar 2022 14:25:03 +0100 Subject: [PATCH] Fix Android not supporting string.replaceAll (#91) Signed-off-by: Emanuele Feliziani --- dist/autofill.js | 4 ++-- src/Form/formatters.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/autofill.js b/dist/autofill.js index 77754eb79..e26f059d1 100644 --- a/dist/autofill.js +++ b/dist/autofill.js @@ -5060,7 +5060,7 @@ const getCountryName = function (el) { if (el.nodeName === 'SELECT') { const englishCountryName = getCountryDisplayName('en', addressCountryCode); // This regex matches both the localised and English country names - const countryNameRegex = new RegExp(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["", "|", ""])), localisedCountryName.replaceAll(' ', '.?'), englishCountryName.replaceAll(' ', '.?')), 'i'); + const countryNameRegex = new RegExp(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["", "|", ""])), localisedCountryName.replace(/ /g, '.?'), englishCountryName.replace(/ /g, '.?')), 'i'); const countryCodeRegex = new RegExp(String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\b", "\b"], ["\\b", "\\b"])), addressCountryCode), 'i'); // We check the country code first because it's more accurate if (el instanceof HTMLSelectElement) { @@ -5230,7 +5230,7 @@ const prepareFormValuesForStorage = formValues => { } if (creditCards.cardNumber) { - creditCards.cardNumber = creditCards.cardNumber.replaceAll(/\D/g, ''); + creditCards.cardNumber = creditCards.cardNumber.replace(/\D/g, ''); } } else { creditCards = undefined; diff --git a/src/Form/formatters.js b/src/Form/formatters.js index d9dfff042..c1bf3f542 100644 --- a/src/Form/formatters.js +++ b/src/Form/formatters.js @@ -84,9 +84,9 @@ const getCountryName = (el, options = {}) => { const englishCountryName = getCountryDisplayName('en', addressCountryCode) // This regex matches both the localised and English country names const countryNameRegex = new RegExp(String.raw`${ - localisedCountryName.replaceAll(' ', '.?') + localisedCountryName.replace(/ /g, '.?') }|${ - englishCountryName.replaceAll(' ', '.?') + englishCountryName.replace(/ /g, '.?') }`, 'i') const countryCodeRegex = new RegExp(String.raw`\b${addressCountryCode}\b`, 'i') @@ -237,7 +237,7 @@ const prepareFormValuesForStorage = (formValues) => { creditCards.expirationYear = `${Number(creditCards.expirationYear) + 2000}` } if (creditCards.cardNumber) { - creditCards.cardNumber = creditCards.cardNumber.replaceAll(/\D/g, '') + creditCards.cardNumber = creditCards.cardNumber.replace(/\D/g, '') } } else { creditCards = undefined