fix(core): asset loading not decoding percent-encoded path, closes #1879 (#1938)

This commit is contained in:
Lucas Fernandes Nogueira 2021-06-01 15:49:24 -03:00 committed by GitHub
parent 40b717edc5
commit c021968eb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch
---
Fixes custom protocol asset loader not decoding the percent-encoded path.

View File

@ -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

View File

@ -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()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -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