diff --git a/examples/api/src-tauri/capabilities/base.json b/examples/api/src-tauri/capabilities/base.json index ae93aeef..92532e7d 100644 --- a/examples/api/src-tauri/capabilities/base.json +++ b/examples/api/src-tauri/capabilities/base.json @@ -81,6 +81,10 @@ "deny": ["$APPDATA/db/*.stronghold"] }, "store:default", - "opener:default" + "opener:default", + { + "identifier": "opener:allow-open-path", + "allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }] + } ] } diff --git a/examples/api/src/views/Opener.svelte b/examples/api/src/views/Opener.svelte index 3a2afaab..5cc16b20 100644 --- a/examples/api/src/views/Opener.svelte +++ b/examples/api/src/views/Opener.svelte @@ -1,5 +1,5 @@ -
+
+
+ + + + + with + +
+
+ + with - {#each programs as p} {/each} +
- +
+ + +
diff --git a/plugins/opener/src/commands.rs b/plugins/opener/src/commands.rs index 09d41b10..aa38a5c3 100644 --- a/plugins/opener/src/commands.rs +++ b/plugins/opener/src/commands.rs @@ -16,7 +16,7 @@ pub async fn open_url( app: AppHandle, command_scope: CommandScope, global_scope: GlobalScope, - path: String, + url: String, with: Option, ) -> crate::Result<()> { let scope = Scope::new( @@ -33,10 +33,10 @@ pub async fn open_url( .collect(), ); - if scope.is_url_allowed(&path) { - crate::open_url(path, with) + if scope.is_url_allowed(&url) { + crate::open_url(url, with) } else { - Err(Error::ForbiddenUrl(path)) + Err(Error::ForbiddenUrl(url)) } }