Skip to content

Commit

Permalink
feat(core): fallback to {path}.html in Tauri protocol loader ref #3887
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Apr 22, 2022
1 parent 47be351 commit 7864d41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/asset-default-ext-fallback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Fallback to `{path}.html` when `{path}` is not found in the Tauri custom protocol handler.
14 changes: 13 additions & 1 deletion core/tauri/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,14 +751,26 @@ impl<R: Runtime> WindowManager<R> {
let asset_response = assets
.get(&path.as_str().into())
.or_else(|| {
eprintln!("Asset `{}` not found; fallback to {}.html", path, path);
let fallback = format!("{}.html", path.as_str()).into();
let asset = assets.get(&fallback);
asset_path = fallback;
asset
})
.or_else(|| {
#[cfg(debug_assertions)]
eprintln!(
"Asset `{}` not found; fallback to {}/index.html",
path, path
);
let fallback = format!("{}/index.html", path.as_str()).into();
let asset = assets.get(&fallback);
asset_path = fallback;
asset
})
.or_else(|| {
#[cfg(debug_assertions)]
eprintln!("Asset `{}` not found; fallback to index.html", path); // TODO log::error!
eprintln!("Asset `{}` not found; fallback to index.html", path);
let fallback = AssetKey::from("index.html");
let asset = assets.get(&fallback);
asset_path = fallback;
Expand Down

0 comments on commit 7864d41

Please sign in to comment.