blacklist as an util
This commit is contained in:
parent
327144a3aa
commit
cf0dcf2522
3 changed files with 65 additions and 21 deletions
13
src/shared/blacklists.js
Normal file
13
src/shared/blacklists.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import * as re from 'shared/utils/re';
|
||||
|
||||
const includes = (blacklist, url) => {
|
||||
let u = new URL(url)
|
||||
return blacklist.some((item) => {
|
||||
if (!item.includes('/')) {
|
||||
return re.fromWildcard(item).test(u.hostname);
|
||||
}
|
||||
return re.fromWildcard(item).test(u.hostname + u.pathname);
|
||||
});
|
||||
}
|
||||
|
||||
export { includes };
|
Reference in a new issue