From 8b19d5e72c3244213ce9f69e93603b1c672b854d Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Thu, 25 Apr 2024 21:54:12 +0400 Subject: [PATCH] Electron: Correctly identify local contents pathname on Windows (#4503) --- src/electron/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/electron/utils.ts b/src/electron/utils.ts index d97b5900b..c582c2b03 100644 --- a/src/electron/utils.ts +++ b/src/electron/utils.ts @@ -68,7 +68,11 @@ export function checkIsWebContentsUrlAllowed(url: string): boolean { const parsedUrl = new URL(url); - if (parsedUrl.pathname === encodeURI(`${__dirname}/index.html`)) { + const localContentsPathname = IS_WINDOWS + ? encodeURI(`/${__dirname.replace(/\\/g, '/')}/index.html`) + : encodeURI(`${__dirname}/index.html`); + + if (parsedUrl.pathname === localContentsPathname) { return true; }