From f4cfadedd09918d6adb410ce4376450b50286bc2 Mon Sep 17 00:00:00 2001 From: MicaiahReid Date: Thu, 21 Apr 2022 14:04:53 -0400 Subject: [PATCH] wrap new URL in try/catch --- .../rpc-method-middleware/handlers/add-ethereum-chain.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js b/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js index 8b5ff8bbe835..db3f4ac1fbb7 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js @@ -78,8 +78,12 @@ async function addEthereumChainHandler( } const isLocalhost = (strUrl) => { - const url = new URL(strUrl); - return url.hostname === 'localhost' || url.hostname === '127.0.0.1'; + try { + const url = new URL(strUrl); + return url.hostname === 'localhost' || url.hostname === '127.0.0.1'; + } catch (error) { + return false; + } }; const firstValidRPCUrl = Array.isArray(rpcUrls)