blacklist as an util

This commit is contained in:
Shin'ya Ueoka 2018-07-07 17:52:01 +09:00
parent 327144a3aa
commit cf0dcf2522
3 changed files with 65 additions and 21 deletions

13
src/shared/blacklists.js Normal file
View 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 };