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 { 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:":
|
||||||
|
|
Loading…
Reference in a new issue