@@ -13,16 +13,18 @@ const getGlobalProxyDetails = async (): Promise<ProxyDetails> => {
13
13
} ;
14
14
15
15
export const getActiveTabDetails = async ( ) => {
16
- const activeWindow = await browser . windows . getCurrent ( { populate : true } ) ;
17
- const activeTab = activeWindow . tabs ! . find ( ( tab ) => tab . active ) ;
18
- const activeTabURL = new URL ( activeTab ! . url ! ) ;
19
-
20
- return activeTabURL
21
- ? {
22
- host : activeTabURL . hostname ,
23
- protocol : activeTabURL . protocol ,
24
- }
25
- : { host : '' , protocol : '' } ;
16
+ const [ activeTab ] = await browser . tabs . query ( { active : true , currentWindow : true } ) ;
17
+
18
+ // activeTab will be null if tabs permission has not been granted
19
+ if ( ! activeTab ?. url ) {
20
+ return { host : '' , protocol : '' } ;
21
+ }
22
+
23
+ const activeTabURL = new URL ( activeTab . url ) ;
24
+ return {
25
+ host : activeTabURL . hostname ,
26
+ protocol : activeTabURL . protocol ,
27
+ } ;
26
28
} ;
27
29
28
30
export const getActiveProxyDetails = async ( ) => {
@@ -31,8 +33,8 @@ export const getActiveProxyDetails = async () => {
31
33
32
34
if ( hostProxiesDetails ) {
33
35
const hostProxiesDetailsParsed = JSON . parse ( hostProxiesDetails ) ;
34
- const activeTab = await browser . tabs . query ( { active : true , currentWindow : true } ) ;
35
- const tabHost = new URL ( activeTab [ 0 ] . url ! ) . hostname ;
36
+ const [ activeTab ] = await browser . tabs . query ( { active : true , currentWindow : true } ) ;
37
+ const tabHost = new URL ( activeTab . url ! ) . hostname ;
36
38
const { domain } = checkDomain ( tabHost ) ;
37
39
38
40
// Check subdomain proxy first
0 commit comments