Skip to content

Commit

Permalink
Fix Android not supporting string.replaceAll (#91)
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuele Feliziani <feliziani.emanuele@gmail.com>
  • Loading branch information
GioSensation authored Mar 10, 2022
1 parent 3481e3f commit d408f97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Form/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d408f97

Please sign in to comment.