File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -266,7 +266,11 @@ app.whenReady().then(async () => {
266266 try {
267267 const url = new URL ( request . url ) ;
268268 // Decode the path from URL encoding
269- const requestedPath = decodeURIComponent ( url . pathname . substring ( 1 ) ) ; // Remove leading /
269+ let requestedPath = decodeURIComponent ( url . pathname ) ;
270+ // On Windows, URL pathname has extra leading / before drive letter (e.g., /C:/...)
271+ if ( / ^ \/ [ A - Z ] : / i. test ( requestedPath ) ) {
272+ requestedPath = requestedPath . substring ( 1 ) ;
273+ }
270274 const normalizedRequested = path . normalize ( requestedPath ) ;
271275 const normalizedAssetsDir = path . normalize ( assetsDir ) ;
272276
Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
7171 if ( ! platformPath ) return null ;
7272 // Normalize path separators to forward slashes for URL
7373 const normalizedPath = platformPath . replace ( / \\ / g, '/' ) ;
74- return `asset://localhost/${ encodeURIComponent ( normalizedPath ) } ` ;
74+ // Encode each path segment individually to preserve URL path structure (like Tauri's convertFileSrc)
75+ const encodedPath = normalizedPath . split ( '/' ) . map ( segment => encodeURIComponent ( segment ) ) . join ( '/' ) ;
76+ return `asset://localhost${ encodedPath } ` ;
7577 } ,
7678
7779 // Set zoom factor on the webview (mirrors Tauri's zoom_window)
You can’t perform that action at this time.
0 commit comments