Skip to content

Commit 7864d41

Browse files
authored
feat(core): fallback to {path}.html in Tauri protocol loader ref #3887 (#3939)
1 parent 47be351 commit 7864d41

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

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+
Fallback to `{path}.html` when `{path}` is not found in the Tauri custom protocol handler.

core/tauri/src/manager.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,26 @@ impl<R: Runtime> WindowManager<R> {
751751
let asset_response = assets
752752
.get(&path.as_str().into())
753753
.or_else(|| {
754+
eprintln!("Asset `{}` not found; fallback to {}.html", path, path);
755+
let fallback = format!("{}.html", path.as_str()).into();
756+
let asset = assets.get(&fallback);
757+
asset_path = fallback;
758+
asset
759+
})
760+
.or_else(|| {
761+
#[cfg(debug_assertions)]
762+
eprintln!(
763+
"Asset `{}` not found; fallback to {}/index.html",
764+
path, path
765+
);
754766
let fallback = format!("{}/index.html", path.as_str()).into();
755767
let asset = assets.get(&fallback);
756768
asset_path = fallback;
757769
asset
758770
})
759771
.or_else(|| {
760772
#[cfg(debug_assertions)]
761-
eprintln!("Asset `{}` not found; fallback to index.html", path); // TODO log::error!
773+
eprintln!("Asset `{}` not found; fallback to index.html", path);
762774
let fallback = AssetKey::from("index.html");
763775
let asset = assets.get(&fallback);
764776
asset_path = fallback;

0 commit comments

Comments
 (0)