From e9a38c8eda7d74d11104431ac6c25bd2f0634028 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 3 Dec 2017 06:14:02 +0300 Subject: [PATCH] fixup 387193d3: don't try to parse unsupported URLs --- popup/popup.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/popup/popup.js b/popup/popup.js index 6bba06f4..6b90bfb9 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -105,19 +105,20 @@ function initPopup(url) { installed); } - const u = new URL(url); - $('#find-styles-link').onclick = handleEvent.openURLandHide; - $('#find-styles-link').href += - url.startsWith(location.protocol) ? '?search_terms=Stylus' : - u.protocol === 'file:' ? 'file:' : - u.hostname.replace(/^www\.|(\.com?)?\.\w+$/g, '').split('.').pop(); - if (!url) { document.body.classList.add('blocked'); document.body.insertBefore(template.unavailableInfo, document.body.firstChild); return; } + const u = tryCatch(() => new URL(url)); + $('#find-styles-link').onclick = handleEvent.openURLandHide; + $('#find-styles-link').href += + !u ? '' : + u.protocol === 'file:' ? 'file:' : + u.protocol === location.protocol ? '?search_terms=Stylus' : + u.hostname.replace(/^www\.|(\.com?)?\.\w+$/g, '').split('.').pop(); + getActiveTab().then(function ping(tab, retryCountdown = 10) { sendMessage({tabId: tab.id, method: 'ping', frameId: 0}, pong => { if (pong) {