diff --git a/src/main/index.ts b/src/main/index.ts index b697fe4..6cc60b6 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -72,7 +72,8 @@ function init() { if (isDeckGameMode) nativeTheme.themeSource = "dark"; app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => { - data.IS_DEV ? app.quit() : restoreVesktop(); + if (data.IS_DEV) app.quit(); + else restoreVesktop(); }); app.whenReady().then(async () => { diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 65eedd3..0a203f9 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -457,12 +457,13 @@ function createMainWindow() { let uriFiredDarwin = false; app.on("open-url", (_, url) => { - uriFiredDarwin ? restoreVesktop() : loadUrl(url); + if (uriFiredDarwin) restoreVesktop(); + else loadUrl(url); uriFiredDarwin = true; }); const uri = process.argv.find(arg => arg.startsWith("discord://")); - uriFiredDarwin || loadUrl(uri); + if (!uriFiredDarwin) loadUrl(uri); return win; } @@ -472,7 +473,7 @@ const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDeskto export function loadUrl(uri: string | undefined) { const branch = Settings.store.discordBranch; const subdomain = branch === "canary" || branch === "ptb" ? `${branch}.` : ""; - mainWin.loadURL(`https://${subdomain}discord.com/${uri?.replace(RegExp("^discord://[^/]*/?"), "") || "app"}`); + mainWin.loadURL(`https://${subdomain}discord.com/${uri ? new URL(uri).pathname.slice(1) || "app" : "app"}`); } export function restoreVesktop() {