Skip to content

Commit 27de615

Browse files
committed
allow regex in blocklist
1 parent 903386c commit 27de615

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/worker/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ import about from '../global/util/about';
144144

145145
if (request.url.startsWith(__dynamic.config.bare.path.toString())) return false;
146146
if (request.url.startsWith(location.origin + self.__dynamic$config.prefix)) return true;
147-
if (blockList.includes(request.url)) return false;
148147

149148
if (request.mode !== 'navigate') request.client = (await self.clients.matchAll()).find((e:any)=>e.id==event.clientId);
150149

@@ -221,7 +220,7 @@ import about from '../global/util/about';
221220

222221
Dynamic.meta.load(new URL(Dynamic.url.decode(new URL(request.url))));
223222

224-
if (blockList.indexOf(Dynamic.meta.host) !== -1) return (this.fire('blocked', [Dynamic.meta, request]) || new Response(null, {
223+
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, {
225224
status: 403,
226225
statusText: 'Forbidden'
227226
}));

0 commit comments

Comments
 (0)