From 58a84dfca33170db2e98faf3256139f4619bfc6b Mon Sep 17 00:00:00 2001 From: GoMinO Date: Thu, 12 Mar 2020 22:29:09 +0100 Subject: [PATCH] fix(isIBAN): only strip spaces and hyphens before validating IBAN --- src/lib/isIBAN.js | 6 +++--- test/validators.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/isIBAN.js b/src/lib/isIBAN.js index cb753acf6..5b6da5952 100644 --- a/src/lib/isIBAN.js +++ b/src/lib/isIBAN.js @@ -94,12 +94,12 @@ const ibanRegexThroughCountryCode = { * @return {boolean} */ function hasValidIbanFormat(str) { - // Strip white spaces and hyphens, keep only digits and A-Z latin alphabetic - const strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); + // Strip white spaces and hyphens + const strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase(); const isoCountryCode = strippedStr.slice(0, 2).toUpperCase(); return (isoCountryCode in ibanRegexThroughCountryCode) && - ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr); + ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr); } /** diff --git a/test/validators.js b/test/validators.js index 9762d84de..999484852 100644 --- a/test/validators.js +++ b/test/validators.js @@ -3823,6 +3823,9 @@ describe('Validators', () => { invalid: [ 'XX22YYY1234567890123', 'FR14 2004 1010 0505 0001 3', + 'FR7630006000011234567890189@', + 'FR7630006000011234567890189๐Ÿ˜…', + 'FR763000600001123456!!๐Ÿคจ7890189@', ], }); });