Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nortonandreev committed Feb 22, 2024
1 parent 9eb65d5 commit 783a55a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions web-wallet/src/lib/dusk/string/__tests__/validateAddress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion web-wallet/src/lib/dusk/string/validateAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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." };
Expand Down

0 comments on commit 783a55a

Please sign in to comment.