From a294ca71257d7c85111d13ea7e636aa23dd5d689 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 2 Jul 2020 18:01:04 -0300 Subject: [PATCH] Set empty active tab if origin is invalid (#8890) The `activeTab` state is now set to an empty object if the `origin` of the active tab is missing or invalid. It can be invalid if the URL passed to the `URL` constructor is missing a scheme (e.g. `about: blank`). There are currently no cases where the rest of the data in `activeTab` is useful in the absence of an `origin`. This will make upcoming UI logic changes a bit simpler than they would be otherwise. Now we can assume that if any property is set on `activeTab`, it must have a valid `origin`. --- app/scripts/ui.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/scripts/ui.js b/app/scripts/ui.js index 5e8cc8e66..3b7b6ea3c 100644 --- a/app/scripts/ui.js +++ b/app/scripts/ui.js @@ -86,6 +86,11 @@ async function queryCurrentActiveTab (windowType) { const { title, url } = activeTab const { origin, protocol } = url ? new URL(url) : {} + if (!origin || origin === 'null') { + resolve({}) + return + } + resolve({ title, origin, protocol, url }) }) })