Skip to content

Commit

Permalink
fix(core): asset loading not decoding percent-encoded path, closes #1879
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Jun 1, 2021
1 parent 40b717e commit c021968
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-asset-loading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Fixes custom protocol asset loader not decoding the percent-encoded path.
1 change: 1 addition & 0 deletions core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ http = "0.2"
state = "0.4"
bincode = "1.3"
dirs-next = "2.0"
percent-encoding = "2.1"

# FS
base64 = { version = "0.13", optional = true } # also used on the updater
Expand Down
3 changes: 3 additions & 0 deletions core/tauri/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ impl<P: Params> WindowManager<P> {
if path.ends_with('/') {
path.pop();
}
path = percent_encoding::percent_decode(path.as_bytes())
.decode_utf8_lossy()
.to_string();
let path = if path.is_empty() {
// if the url is `tauri://localhost`, we should load `index.html`
"index.html".to_string()
Expand Down
4 changes: 2 additions & 2 deletions examples/api/public/build/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/api/public/build/bundle.js.map

Large diffs are not rendered by default.

File renamed without changes
2 changes: 1 addition & 1 deletion examples/api/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<main>
<div class="flex row noselect just-around" style="margin=1em;" data-tauri-drag-region>
<img src="tauri.png" height="60" on:click={onLogoClick} alt="logo" />
<img src="tauri logo.png" height="60" on:click={onLogoClick} alt="logo" />
<div>
<a class="dark-link" target="_blank" href="https://tauri.studio/en/docs/getting-started/intro">
Documentation
Expand Down

0 comments on commit c021968

Please sign in to comment.