1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

perf: improved ipc validation on Linux

This commit is contained in:
2023-09-13 16:30:08 +02:00
parent 13592425af
commit 9de5f67d18
2 changed files with 6 additions and 2 deletions

View File

@ -2,10 +2,14 @@ import { WebFrameMain } from 'electron';
import * as path from 'path';
const isDevelopment = process.env.NODE_ENV !== 'production';
const isWindows = process.platform === 'win32';
const indexPath = path.resolve(__dirname, 'index.html').split(path.sep).join('/');
export function validateSender (frame: WebFrameMain) {
const frameUrl = new URL(frame.url);
if ((isDevelopment && frameUrl.host === 'localhost:9080') || frameUrl.href.replace('file:///', '').replace('file://localhost', '') === indexPath) return true;
const prefix = isWindows ? 'file:///' : 'file://';
const framePath = frameUrl.href.replace(prefix, '');
if ((isDevelopment && frameUrl.host === 'localhost:9080') || framePath === indexPath) return true;
return false;
}