Skip to content

Commit 46c6b6d

Browse files
committed
Injecting storage
1 parent 142b0bd commit 46c6b6d

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export function extractHostname(url:string | undefined):string {
2+
let hostname;
3+
if (url == undefined) return '';
4+
5+
if (url.indexOf("//") > -1) {
6+
hostname = url.split('/')[2];
7+
}
8+
else {
9+
hostname = url.split('/')[0];
10+
}
11+
12+
hostname = hostname.split(':')[0];
13+
hostname = hostname.split('?')[0];
14+
15+
return hostname;
16+
}

src/compositions/valid-page.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Browser from 'webextension-polyfill';
2+
3+
export function isValidPage(tab: Browser.Tabs.Tab): boolean{
4+
if (tab == null || tab == undefined || !tab.url) return false;
5+
6+
if ((tab.url.indexOf('http:') == -1 && tab.url.indexOf('https:') == -1)
7+
|| tab.url.indexOf('chrome://') !== -1
8+
|| tab.url.indexOf('chrome-extension://') !== -1)
9+
return false;
10+
return true;
11+
}

src/storage/inject-storage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { LocalStorage } from "./local-storage";
2+
import { IStorage } from "./storage-interface";
3+
4+
export function injecStorage(): IStorage {
5+
return new LocalStorage();
6+
}

src/storage/local-storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IStorage } from "./storage";
1+
import { IStorage } from "./storage-interface";
22
import { StorageParams } from "./storage-params";
33
import { Tab } from "./tab";
44
import Browser from 'webextension-polyfill';

0 commit comments

Comments
 (0)