Skip to content

Commit 5909c1e

Browse files
authored
Make sure custom protocol is handled as secure context on macOS (#1551)
1 parent 422dd5e commit 5909c1e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Make sure custom protocol is treated as secure content on macOS.

core/tauri/src/runtime/manager.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ impl<P: Params> WindowManager<P> {
133133
if self.inner.config.build.dev_path.starts_with("http") {
134134
self.inner.config.build.dev_path.clone()
135135
} else {
136-
format!("tauri://{}", self.inner.config.tauri.bundle.identifier)
136+
"tauri://localhost".into()
137137
}
138138
}
139139

140140
#[cfg(custom_protocol)]
141141
fn get_url(&self) -> String {
142-
format!("tauri://{}", self.inner.config.tauri.bundle.identifier)
142+
"tauri://localhost".into()
143143
}
144144

145145
fn prepare_attributes(
@@ -240,7 +240,6 @@ impl<P: Params> WindowManager<P> {
240240

241241
fn prepare_custom_protocol(&self) -> CustomProtocol {
242242
let assets = self.inner.assets.clone();
243-
let bundle_identifier = self.inner.config.tauri.bundle.identifier.clone();
244243
CustomProtocol {
245244
handler: Box::new(move |path| {
246245
let mut path = path
@@ -249,12 +248,12 @@ impl<P: Params> WindowManager<P> {
249248
.next()
250249
.unwrap()
251250
.to_string()
252-
.replace(&format!("tauri://{}", bundle_identifier), "");
251+
.replace("tauri://localhost", "");
253252
if path.ends_with('/') {
254253
path.pop();
255254
}
256255
let path = if path.is_empty() {
257-
// if the url is `tauri://${appId}`, we should load `index.html`
256+
// if the url is `tauri://localhost`, we should load `index.html`
258257
"index.html".to_string()
259258
} else {
260259
// skip leading `/`
@@ -385,7 +384,7 @@ mod test {
385384
);
386385

387386
#[cfg(custom_protocol)]
388-
assert_eq!(manager.get_url(), "tauri://studio.tauri.example");
387+
assert_eq!(manager.get_url(), "tauri://localhost");
389388

390389
#[cfg(dev)]
391390
assert_eq!(manager.get_url(), manager.config().build.dev_path);

0 commit comments

Comments
 (0)