From 90407c49c65e8709fab7dfc2922307418d3ca258 Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Sun, 25 Jan 2026 21:50:17 +1100 Subject: [PATCH] feat: add open_external_url command to open URLs in the default browser --- cinny | 2 +- src-tauri/Cargo.lock | 1 + src-tauri/Cargo.toml | 1 + src-tauri/src/lib.rs | 9 ++++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cinny b/cinny index 5461359..47b24d2 160000 --- a/cinny +++ b/cinny @@ -1 +1 @@ -Subproject commit 546135988ec3d7182ef07ff1b02f84d5d99dcaa8 +Subproject commit 47b24d26fff139a1545794a4ca666cce396f8326 diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 37b6776..2c41374 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2681,6 +2681,7 @@ version = "4.10.2" dependencies = [ "arboard", "base64 0.22.1", + "open", "png 0.17.16", "ppv-lite86", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 52d9568..e7355d2 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -39,6 +39,7 @@ tauri-plugin-window-state = "2" tauri-plugin-single-instance = "2" tauri-plugin-updater = "2" tauri-plugin-autostart = "2" +open = "5" [features] default = ["custom-protocol"] diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 5759068..342341c 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -51,6 +51,13 @@ fn read_clipboard_image() -> Result, String> { Ok(None) } +/// Open a URL in the default browser (bypasses ACL issues with localhost plugin) +#[cfg(not(any(target_os = "android", target_os = "ios")))] +#[tauri::command] +fn open_external_url(url: String) -> Result<(), String> { + open::that(&url).map_err(|e| e.to_string()) +} + /// Runs the Tauri application pub fn run() { #[cfg(not(any(target_os = "android", target_os = "ios")))] @@ -157,7 +164,7 @@ pub fn run() { api.prevent_close(); } }) - .invoke_handler(tauri::generate_handler![read_clipboard_image]) + .invoke_handler(tauri::generate_handler![read_clipboard_image, open_external_url]) .run(tauri::generate_context!()) .expect("error while building tauri application"); }