1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(permissions): add information about import() API request (#17149)

This commit changes permission prompt to show that "import()" API
is requesting permissions.

Given "dynamic_import.js" like so:
```
import("https://deno.land/std@0.170.0/version.ts");
```

Before:
```
deno run dynamic_import.js
⚠️  ┌ Deno requests net access to "deno.land".
   ├ Run again with --allow-net to bypass this prompt.
   └ Allow? [y/n] (y = yes, allow; n = no, deny) > 

```

After:
```
deno run dynamic_import.js
⚠️  ┌ Deno requests net access to "deno.land".
   ├ Requested by `import()` API
   ├ Run again with --allow-net to bypass this prompt.
   └ Allow? [y/n] (y = yes, allow; n = no, deny) >

```
This commit is contained in:
Bartek Iwańczuk 2022-12-21 14:24:39 +01:00 committed by GitHub
parent 6a47ffa4d3
commit 4258e06f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1601,7 +1601,7 @@ impl Permissions {
) -> Result<(), AnyError> {
match specifier.scheme() {
"file" => match specifier.to_file_path() {
Ok(path) => self.read.check(&path, None),
Ok(path) => self.read.check(&path, Some("import()")),
Err(_) => Err(uri_error(format!(
"Invalid file path.\n Specifier: {}",
specifier
@ -1609,7 +1609,7 @@ impl Permissions {
},
"data" => Ok(()),
"blob" => Ok(()),
_ => self.net.check_url(specifier, None),
_ => self.net.check_url(specifier, Some("import()")),
}
}
}