Fix adding connections & popout on ptb/canary
This commit is contained in:
parent
15a49a31e1
commit
38f0330eb2
1 changed files with 10 additions and 8 deletions
|
@ -9,20 +9,22 @@ import { BrowserWindow, shell } from "electron";
|
|||
import { Settings } from "../settings";
|
||||
import { execSteamURL, isDeckGameMode, steamOpenURL } from "./steamOS";
|
||||
|
||||
const DISCORD_HOSTNAMES = ["discord.com", "canary.discord.com", "ptb.discord.com"];
|
||||
export function makeLinksOpenExternally(win: BrowserWindow) {
|
||||
win.webContents.setWindowOpenHandler(({ url }) => {
|
||||
switch (url) {
|
||||
case "about:blank":
|
||||
case "https://discord.com/popout":
|
||||
return { action: "allow" };
|
||||
}
|
||||
|
||||
win.webContents.setWindowOpenHandler(({ url, frameName }) => {
|
||||
try {
|
||||
var { protocol } = new URL(url);
|
||||
var { protocol, hostname, pathname } = new URL(url);
|
||||
} catch {
|
||||
return { action: "deny" };
|
||||
}
|
||||
|
||||
if (
|
||||
url === "about:blank" ||
|
||||
(pathname === "/popout" && DISCORD_HOSTNAMES.includes(hostname)) ||
|
||||
(frameName === "authorize" && DISCORD_HOSTNAMES.includes(hostname))
|
||||
)
|
||||
return { action: "allow" };
|
||||
|
||||
switch (protocol) {
|
||||
case "http:":
|
||||
case "https:":
|
||||
|
|
Loading…
Reference in a new issue