Skip to content

Commit 9d45c6e

Browse files
committed
Change active tab module
1 parent 6021a31 commit 9d45c6e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/compositions/activeTab.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import { extractHostname } from "./extract-hostname";
2+
13
export class ActiveTab {
24
private static instance: ActiveTab;
3-
private _activeTab: string | null;
5+
private _activeTabUrl: string | null;
6+
private _activeTabDomain: string | null;
47

58
constructor() {
69
if (ActiveTab.instance) {
710
throw new Error("Error - use ActiveTab.getInstance()");
811
}
9-
this._activeTab = null;
12+
this._activeTabUrl = null;
13+
this._activeTabDomain = null;
1014
}
1115

1216
static getInstance(): ActiveTab {
@@ -16,11 +20,17 @@ export class ActiveTab {
1620

1721
public setActiveTab(value:string | null): void
1822
{
19-
this._activeTab = value;
23+
this._activeTabUrl = value;
24+
this._activeTabDomain = value != null ? extractHostname(value) : null;
25+
}
26+
27+
public getActiveTabUrl(): string | null
28+
{
29+
return this._activeTabUrl;
2030
}
2131

22-
public getActiveTab(): string | null
32+
public getActiveTabDomain(): string | null
2333
{
24-
return this._activeTab;
34+
return this._activeTabDomain;
2535
}
2636
}

0 commit comments

Comments
 (0)