diff --git a/web-wallet/src/lib/dusk/string/__tests__/validateAddress.spec.js b/web-wallet/src/lib/dusk/string/__tests__/validateAddress.spec.js index d780b17740..24eadd3532 100644 --- a/web-wallet/src/lib/dusk/string/__tests__/validateAddress.spec.js +++ b/web-wallet/src/lib/dusk/string/__tests__/validateAddress.spec.js @@ -23,8 +23,26 @@ describe("validateAddress", () => { // Empty string "", - // Contains an invalid character - "47jNTgAhzn9KCKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnM!" + // Contains an invalid character (!) + "47jNTgAhzn9KCKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnM!", + + // Contains an invalid character (_) + "47jNTgAhzn9_CKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnM", + + // Contains an invalid character ( ) + "47jNTgAhzn9 CKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnM", + + // Contains an invalid character (0) + "47jNTgAhzn0KCKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnMM", + + // Contains an invalid character (O) + "47jNTgAhznOKCKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnMM", + + // Contains an invalid character (l) + "47jNTgAhznlKCKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnMM", + + // Contains an invalid character (l) + "47jNTgAhznIKCKF3msCfvKg3k1P1QpPCLZ3HG3AoNp87sQ5WNS3QyjckYHWeuXqW7uvLmbKgejpP8Xkcip89vnMM" ]; it("passes when supplied with a valid address", () => { diff --git a/web-wallet/src/lib/dusk/string/validateAddress.js b/web-wallet/src/lib/dusk/string/validateAddress.js index 8e10f389a6..f9415c03ba 100644 --- a/web-wallet/src/lib/dusk/string/validateAddress.js +++ b/web-wallet/src/lib/dusk/string/validateAddress.js @@ -6,7 +6,7 @@ * - `reason` {String} - describes why the address is invalid or confirms if it is valid. */ export default function validateAddress (address) { - const regex = /[^\w]/g; + const regex = /[\W_0OIl]/; if (address.length < 87 || address.length > 88) { return { isValid: false, reason: "Invalid length. Addresses must be 87 or 88 characters long." };