Skip to content

Commit

Permalink
fix(custom-protocol): Make sure custom protocol is handled as secure …
Browse files Browse the repository at this point in the history
…content on macOS

Do not seems to affect other platform need to test on Windows and linux to be sure it didn’t break anything.

Fix #1550
  • Loading branch information
lemarier committed Apr 20, 2021
1 parent 8fa06dd commit b928673
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/macos-custom-protocol-https.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Make sure custom protocol is treated as secure content on macOS.
9 changes: 4 additions & 5 deletions core/tauri/src/runtime/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ impl<P: Params> WindowManager<P> {
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(
Expand Down Expand Up @@ -225,7 +225,6 @@ impl<P: Params> WindowManager<P> {

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| {
Expand All @@ -235,12 +234,12 @@ impl<P: Params> WindowManager<P> {
.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 `/`
Expand Down

0 comments on commit b928673

Please sign in to comment.