about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHailey <153161762+haileyok@users.noreply.github.com>2023-12-26 12:02:37 -0800
committerGitHub <noreply@github.com>2023-12-26 12:02:37 -0800
commit7e3e6caa1020c6894008dd14ef6ce0e2555920c0 (patch)
tree8d98162b8449bab69f12a3c2d386b7cb43959028 /src
parentcd7a25fd4297672083cde28346d926584748ad14 (diff)
downloadvoidsky-7e3e6caa1020c6894008dd14ef6ce0e2555920c0.tar.zst
use the window hostname on web for twitch embeds (#2311)
Diffstat (limited to 'src')
-rw-r--r--src/lib/strings/embed-player.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/strings/embed-player.ts b/src/lib/strings/embed-player.ts
index fdd39280e..ec996dfa5 100644
--- a/src/lib/strings/embed-player.ts
+++ b/src/lib/strings/embed-player.ts
@@ -1,3 +1,5 @@
+import {Platform} from 'react-native'
+
 export type EmbedPlayerParams =
   | {type: 'youtube_video'; videoId: string; playerUri: string}
   | {type: 'twitch_live'; channelId: string; playerUri: string}
@@ -48,12 +50,15 @@ export function parseEmbedPlayerFromUrl(
 
   // twitch
   if (urlp.hostname === 'twitch.tv' || urlp.hostname === 'www.twitch.tv') {
+    const parent =
+      Platform.OS === 'web' ? window.location.hostname : 'localhost'
+
     const parts = urlp.pathname.split('/')
     if (parts.length === 2 && parts[1]) {
       return {
         type: 'twitch_live',
         channelId: parts[1],
-        playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&channel=${parts[1]}&parent=localhost`,
+        playerUri: `https://player.twitch.tv/?volume=0.5&!muted&autoplay&channel=${parts[1]}&parent=${parent}`,
       }
     }
   }