Electron: Correctly identify local contents pathname on Windows (#4503)

This commit is contained in:
Alexander Zinchuk 2024-04-25 21:54:12 +04:00
parent 584f06fafc
commit 8b19d5e72c

View File

@ -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;
}