From 17f1ba3fa4f9dcd86d9a6e8d98fc62f5b9c5a333 Mon Sep 17 00:00:00 2001 From: Owen Date: Wed, 27 Mar 2019 18:40:29 +0900 Subject: [PATCH] Reduce regex memory usaged related to issue #3 --- www/MiniSodium.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/MiniSodium.js b/www/MiniSodium.js index c68682e..084852c 100644 --- a/www/MiniSodium.js +++ b/www/MiniSodium.js @@ -495,7 +495,7 @@ var MiniSodium = { return str; }, is_hex: function(s){ - return typeof s === 'string' && s.length % 2 === 0 && (s.length > 0 ? /^([a-f]|[0-9])+$/ig.test(s) : true); + return typeof s === 'string' && s.length % 2 === 0 && (s.length > 0 ? !(/[^a-f0-9]/ig.test(s)) : true); }, to_string: function(bytes) { //The to_string function from libsodium.js if (typeof TextDecoder === "function") {