Skip to content

Commit 994b532

Browse files
author
Ngo Iok Ui (Wu Yu Wei)
authored
fix: missing asset protocol path (#2484)
1 parent 0391ac3 commit 994b532

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

.changes/asset-path.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"api": patch
3+
"tauri": patch
4+
---
5+
6+
Fix missing asset protocol path.Now the protocol is `https://asset.localhost/path/to/file` on Windows. Lunix and macOS
7+
is still `asset://path/to/file`.

core/tauri/scripts/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tauri/src/manager.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ impl<R: Runtime> WindowManager<R> {
284284
}
285285
if !webview_attributes.has_uri_scheme_protocol("asset") {
286286
webview_attributes = webview_attributes.register_uri_scheme_protocol("asset", move |url| {
287+
#[cfg(target_os = "windows")]
288+
let path = url.replace("asset://localhost/", "");
289+
#[cfg(not(target_os = "windows"))]
287290
let path = url.replace("asset://", "");
288291
let path = percent_encoding::percent_decode(path.as_bytes())
289292
.decode_utf8_lossy()

tooling/api/src/tauri.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function invoke<T>(cmd: string, args: InvokeArgs = {}): Promise<T> {
101101
*/
102102
function convertFileSrc(filePath: string): string {
103103
return navigator.userAgent.includes('Windows')
104-
? `https://asset.${filePath}`
104+
? `https://asset.localhost/${filePath}`
105105
: `asset://${filePath}`
106106
}
107107

0 commit comments

Comments
 (0)