From 007b75e4b42d14a5922bba66e76e18271fbe5052 Mon Sep 17 00:00:00 2001 From: Arnaud Brousseau Date: Fri, 29 Mar 2024 09:50:44 -0500 Subject: [PATCH] Extract hex regex in its own var for readability --- auth/index.html | 3 ++- export/index.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/auth/index.html b/auth/index.html index 2e7167e..24a4cd4 100644 --- a/auth/index.html +++ b/auth/index.html @@ -213,7 +213,8 @@

Message log

* @returns {Uint8Array} */ var uint8arrayFromHexString = function(hexString) { - if (!hexString || hexString.length % 2 != 0 || !/^[0-9A-Fa-f]+$/.test(hexString)) { + var hexRegex = /^[0-9A-Fa-f]+$/; + if (!hexString || hexString.length % 2 != 0 || !hexRegex.test(hexString)) { throw new Error('cannot create uint8array from invalid hex string: "' + hexString + '"'); } return new Uint8Array(hexString.match(/../g).map(h=>parseInt(h,16))); diff --git a/export/index.html b/export/index.html index a55f9ca..f02e314 100644 --- a/export/index.html +++ b/export/index.html @@ -202,7 +202,8 @@

Message log

* @returns {Uint8Array} */ const uint8arrayFromHexString = function(hexString) { - if (!hexString || hexString.length % 2 != 0 || !/^[0-9A-Fa-f]+$/.test(hexString)) { + var hexRegex = /^[0-9A-Fa-f]+$/; + if (!hexString || hexString.length % 2 != 0 || !hexRegex.test(hexString)) { throw new Error('cannot create uint8array from invalid hex string: "' + hexString + '"'); } return new Uint8Array(hexString.match(/../g).map(h=>parseInt(h,16)));