Skip to content

Commit

Permalink
fix: missing asset protocol path (#2484)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngo Iok Ui (Wu Yu Wei) authored Aug 22, 2021
1 parent 0391ac3 commit 994b532
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changes/asset-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"api": patch
"tauri": patch
---

Fix missing asset protocol path.Now the protocol is `https://asset.localhost/path/to/file` on Windows. Lunix and macOS
is still `asset://path/to/file`.
2 changes: 1 addition & 1 deletion core/tauri/scripts/bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions core/tauri/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ impl<R: Runtime> WindowManager<R> {
}
if !webview_attributes.has_uri_scheme_protocol("asset") {
webview_attributes = webview_attributes.register_uri_scheme_protocol("asset", move |url| {
#[cfg(target_os = "windows")]
let path = url.replace("asset://localhost/", "");
#[cfg(not(target_os = "windows"))]
let path = url.replace("asset://", "");
let path = percent_encoding::percent_decode(path.as_bytes())
.decode_utf8_lossy()
Expand Down
2 changes: 1 addition & 1 deletion tooling/api/src/tauri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function invoke<T>(cmd: string, args: InvokeArgs = {}): Promise<T> {
*/
function convertFileSrc(filePath: string): string {
return navigator.userAgent.includes('Windows')
? `https://asset.${filePath}`
? `https://asset.localhost/${filePath}`
: `asset://${filePath}`
}

Expand Down

0 comments on commit 994b532

Please sign in to comment.