1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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`.
This commit is contained in:
Mark Stacey 2020-07-02 18:01:04 -03:00 committed by GitHub
parent 68bcf38a65
commit a294ca7125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,6 +86,11 @@ async function queryCurrentActiveTab (windowType) {
const { title, url } = activeTab const { title, url } = activeTab
const { origin, protocol } = url ? new URL(url) : {} const { origin, protocol } = url ? new URL(url) : {}
if (!origin || origin === 'null') {
resolve({})
return
}
resolve({ title, origin, protocol, url }) resolve({ title, origin, protocol, url })
}) })
}) })