From 27de615a528fdfbb9e93cd418dd46a3372764faa Mon Sep 17 00:00:00 2001 From: Ender <78042486+Sylvie-TN@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:11:27 -0400 Subject: [PATCH] allow regex in blocklist --- lib/worker/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/worker/index.ts b/lib/worker/index.ts index cadcd18e..ba68462b 100644 --- a/lib/worker/index.ts +++ b/lib/worker/index.ts @@ -144,7 +144,6 @@ import about from '../global/util/about'; if (request.url.startsWith(__dynamic.config.bare.path.toString())) return false; if (request.url.startsWith(location.origin + self.__dynamic$config.prefix)) return true; - if (blockList.includes(request.url)) return false; if (request.mode !== 'navigate') request.client = (await self.clients.matchAll()).find((e:any)=>e.id==event.clientId); @@ -221,7 +220,7 @@ import about from '../global/util/about'; Dynamic.meta.load(new URL(Dynamic.url.decode(new URL(request.url)))); - if (blockList.indexOf(Dynamic.meta.host) !== -1) return (this.fire('blocked', [Dynamic.meta, request]) || new Response(null, { + if (blockList.indexOf(Dynamic.meta.host) !== -1 || blockList.find((entry: RegExp) => entry instanceof RegExp && entry.test(Dynamic.meta.host))) return (this.fire('blocked', [Dynamic.meta, request]) || new Response(null, { status: 403, statusText: 'Forbidden' }));