Skip to content

Commit 42e8d9c

Browse files
authored
fix(api): encode file path in convertFileSrc function, closes #3841 (#3846)
1 parent b1f83fd commit 42e8d9c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"api": patch
3+
---
4+
5+
Encode the file path in the `convertFileSrc` function.

tooling/api/src/tauri.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ async function invoke<T>(cmd: string, args: InvokeArgs = {}): Promise<T> {
114114
* @return the URL that can be used as source on the webview.
115115
*/
116116
function convertFileSrc(filePath: string, protocol = 'asset'): string {
117+
const path = encodeURIComponent(filePath)
117118
return navigator.userAgent.includes('Windows')
118-
? `https://${protocol}.localhost/${filePath}`
119-
: `${protocol}://${filePath}`
119+
? `https://${protocol}.localhost/${path}`
120+
: `${protocol}://${path}`
120121
}
121122

122123
export type { InvokeArgs }

0 commit comments

Comments
 (0)