From b92867365cb32f8914a9ab7bd5c48f47422b56e9 Mon Sep 17 00:00:00 2001 From: David Lemarier Date: Tue, 20 Apr 2021 15:17:03 -0400 Subject: [PATCH] fix(custom-protocol): Make sure custom protocol is handled as secure content on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not seems to affect other platform need to test on Windows and linux to be sure it didn’t break anything. Fix #1550 --- .changes/macos-custom-protocol-https.md | 5 +++++ core/tauri/src/runtime/manager.rs | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .changes/macos-custom-protocol-https.md diff --git a/.changes/macos-custom-protocol-https.md b/.changes/macos-custom-protocol-https.md new file mode 100644 index 000000000000..e21ae591c4b5 --- /dev/null +++ b/.changes/macos-custom-protocol-https.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Make sure custom protocol is treated as secure content on macOS. diff --git a/core/tauri/src/runtime/manager.rs b/core/tauri/src/runtime/manager.rs index 9bfcd9231bd0..bc8f8a654e41 100644 --- a/core/tauri/src/runtime/manager.rs +++ b/core/tauri/src/runtime/manager.rs @@ -129,13 +129,13 @@ impl WindowManager

{ if self.inner.config.build.dev_path.starts_with("http") { self.inner.config.build.dev_path.clone() } else { - format!("tauri://{}", self.inner.config.tauri.bundle.identifier) + "tauri://localhost".into() } } #[cfg(custom_protocol)] fn get_url(&self) -> String { - format!("tauri://{}", self.inner.config.tauri.bundle.identifier) + "tauri://localhost".into() } fn prepare_attributes( @@ -225,7 +225,6 @@ impl WindowManager

{ fn prepare_custom_protocol(&self) -> CustomProtocol { let assets = self.inner.assets.clone(); - let bundle_identifier = self.inner.config.tauri.bundle.identifier.clone(); CustomProtocol { name: "tauri".into(), handler: Box::new(move |path| { @@ -235,12 +234,12 @@ impl WindowManager

{ .next() .unwrap() .to_string() - .replace(&format!("tauri://{}", bundle_identifier), ""); + .replace("tauri://localhost", ""); if path.ends_with('/') { path.pop(); } let path = if path.is_empty() { - // if the url is `tauri://${appId}`, we should load `index.html` + // if the url is `tauri://localhost`, we should load `index.html` "index.html".to_string() } else { // skip leading `/`