aboutsummaryrefslogtreecommitdiff
path: root/src/shared/blacklists.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-07-07 17:52:01 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-07-08 11:44:37 +0900
commitcf0dcf25226611590d76d263b5a4acdc89510d09 (patch)
tree93710555c22a088fbdc4ed64c25f5f9f593f8e0a /src/shared/blacklists.js
parent327144a3aa962b51d9b143941be4e626abbc7ee7 (diff)
blacklist as an util
Diffstat (limited to 'src/shared/blacklists.js')
-rw-r--r--src/shared/blacklists.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/shared/blacklists.js b/src/shared/blacklists.js
new file mode 100644
index 0000000..21e3e14
--- /dev/null
+++ b/src/shared/blacklists.js
@@ -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 };