Fix adding connections & popout on ptb/canary

This commit is contained in:
Vendicated 2024-01-15 17:56:33 +01:00
parent 15a49a31e1
commit 38f0330eb2
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -9,20 +9,22 @@ import { BrowserWindow, shell } from "electron";
import { Settings } from "../settings"; import { Settings } from "../settings";
import { execSteamURL, isDeckGameMode, steamOpenURL } from "./steamOS"; import { execSteamURL, isDeckGameMode, steamOpenURL } from "./steamOS";
const DISCORD_HOSTNAMES = ["discord.com", "canary.discord.com", "ptb.discord.com"];
export function makeLinksOpenExternally(win: BrowserWindow) { export function makeLinksOpenExternally(win: BrowserWindow) {
win.webContents.setWindowOpenHandler(({ url }) => { win.webContents.setWindowOpenHandler(({ url, frameName }) => {
switch (url) {
case "about:blank":
case "https://discord.com/popout":
return { action: "allow" };
}
try { try {
var { protocol } = new URL(url); var { protocol, hostname, pathname } = new URL(url);
} catch { } catch {
return { action: "deny" }; return { action: "deny" };
} }
if (
url === "about:blank" ||
(pathname === "/popout" && DISCORD_HOSTNAMES.includes(hostname)) ||
(frameName === "authorize" && DISCORD_HOSTNAMES.includes(hostname))
)
return { action: "allow" };
switch (protocol) { switch (protocol) {
case "http:": case "http:":
case "https:": case "https:":