File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 11import { injecStorage } from "../storage/inject-storage" ;
22import { StorageParams } from "../storage/storage-params" ;
3+ import { isDomainEquals } from "../utils/common" ;
4+ import { extractHostname } from "./extract-hostname" ;
35
46export async function isInBlackList ( url : string ) : Promise < boolean > {
57 const storage = injecStorage ( ) ;
68 const blackList = await storage . getValue ( StorageParams . BLACK_LIST ) as string [ ] ;
7- return blackList != undefined && blackList . indexOf ( url ) != - 1 ? true : false ;
9+ return blackList ?. find ( x => isDomainEquals ( extractHostname ( x ) , extractHostname ( url ) ) ) !== undefined ;
810}
Original file line number Diff line number Diff line change @@ -5,4 +5,20 @@ export function isEmpty(obj: any): boolean {
55 }
66
77 return JSON . stringify ( obj ) === JSON . stringify ( { } ) ;
8+ }
9+
10+ export function isDomainEquals ( first :string , second :string ) {
11+ if ( first === second )
12+ return true ;
13+ else {
14+ var resultUrl = function ( url :string ) {
15+ if ( url . indexOf ( 'www.' ) > - 1 )
16+ return url . split ( 'www.' ) [ 1 ] ;
17+ return url ;
18+ } ;
19+
20+ if ( resultUrl ( first ) === resultUrl ( second ) )
21+ return true ;
22+ else return false ;
23+ }
824}
You can’t perform that action at this time.
0 commit comments