mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
fix: missing asset protocol path (#2484)
This commit is contained in:
committed by
GitHub
parent
0391ac3dc9
commit
994b5325dd
7
.changes/asset-path.md
Normal file
7
.changes/asset-path.md
Normal file
@@ -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`.
|
||||
File diff suppressed because one or more lines are too long
@@ -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()
|
||||
|
||||
@@ -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}`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user