Skip to content

Commit

Permalink
fix(sandbox): use Deno.permissions.request instead of Deno.permission…
Browse files Browse the repository at this point in the history
…s.query (#93)
  • Loading branch information
lino-levan authored Oct 4, 2024
1 parent 46fa35c commit e3e0b7d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,15 @@ export class Page extends EventTarget {
return this.close();
}

//TODO(@lowlighter): change "query" by "request" https://github.com/denoland/deno/issues/14668
async #validateRequest({ request }: Fetch_requestPausedEvent["detail"]) {
const { protocol, host, href } = new URL(request.url);
if (host) {
const { state } = await Deno.permissions.query({ name: "net", host });
const { state } = await Deno.permissions.request({ name: "net", host });
return (state === "granted");
}
if (protocol === "file:") {
const path = fromFileUrl(href);
const { state } = await Deno.permissions.query({ name: "read", path });
const { state } = await Deno.permissions.request({ name: "read", path });
return (state === "granted");
}
return true;
Expand Down

0 comments on commit e3e0b7d

Please sign in to comment.