tangled
alpha
login
or
join now
jeanmachine.dev
/
witchsky.app
forked from
jollywhoppers.com/witchsky.app
0
fork
atom
Bluesky app fork with some witchin' additions 💫
0
fork
atom
overview
issues
pulls
pipelines
fix YouTube and improve Streamplace embeds
xan.lol
1 month ago
b247469e
cccfbd0b
verified
This commit was signed with the committer's
known signature
.
xan.lol
SSH Key Fingerprint:
SHA256:7Zs+dcly5YqxBg7v8XsE1uPMYCobHKBw7CDiNxpmSrY=
+25
-5
2 changed files
expand all
collapse all
unified
split
src
lib
strings
embed-player.ts
handles.ts
+21
-5
src/lib/strings/embed-player.ts
···
1
import {Dimensions} from 'react-native'
0
2
0
3
import {IS_WEB, IS_WEB_SAFARI} from '#/env'
4
5
const {height: SCREEN_HEIGHT} = Dimensions.get('window')
···
11
: 'https://witchsky.app'
12
: __DEV__ && !process.env.JEST_WORKER_ID
13
? 'http://localhost:8100'
14
-
: 'https://witchsky.app'
15
16
export const embedPlayerSources = [
17
'youtube',
···
464
}
465
466
if (urlp.hostname === 'stream.place') {
467
-
return {
468
-
type: 'streamplace_stream',
469
-
source: 'streamplace',
470
-
playerUri: `https://stream.place/embed${urlp.pathname}`,
0
0
471
}
472
}
0
0
0
0
0
0
0
0
0
0
0
0
473
}
474
475
export function getPlayerAspect({
···
1
import {Dimensions} from 'react-native'
2
+
import {isDid} from '@atproto/api'
3
4
+
import {isValidHandle} from '#/lib/strings/handles'
5
import {IS_WEB, IS_WEB_SAFARI} from '#/env'
6
7
const {height: SCREEN_HEIGHT} = Dimensions.get('window')
···
13
: 'https://witchsky.app'
14
: __DEV__ && !process.env.JEST_WORKER_ID
15
? 'http://localhost:8100'
16
+
: 'https://bsky.app'
17
18
export const embedPlayerSources = [
19
'youtube',
···
466
}
467
468
if (urlp.hostname === 'stream.place') {
469
+
if (isValidStreamPlaceUrl(urlp)) {
470
+
return {
471
+
type: 'streamplace_stream',
472
+
source: 'streamplace',
473
+
playerUri: `https://stream.place/embed${urlp.pathname}`,
474
+
}
475
}
476
}
477
+
}
478
+
479
+
function isValidStreamPlaceUrl(urlp: URL): boolean {
480
+
// stream.place URLs should have a path like /did:plc:xxx/... or /handle.bsky.social/...
481
+
const pathParts = urlp.pathname.split('/').filter(Boolean)
482
+
if (pathParts.length === 0) {
483
+
return false
484
+
}
485
+
486
+
// The first part of the path should be either a valid DID or a valid handle
487
+
const identifier = pathParts[0]
488
+
return isDid(identifier) || isValidHandle(identifier)
489
}
490
491
export function getPlayerAspect({
+4
src/lib/strings/handles.ts
···
7
8
export const MAX_SERVICE_HANDLE_LENGTH = 18
9
0
0
0
0
10
export function makeValidHandle(str: string): string {
11
if (str.length > 20) {
12
str = str.slice(0, 20)
···
7
8
export const MAX_SERVICE_HANDLE_LENGTH = 18
9
10
+
export function isValidHandle(handle: string): boolean {
11
+
return VALIDATE_REGEX.test(handle)
12
+
}
13
+
14
export function makeValidHandle(str: string): string {
15
if (str.length > 20) {
16
str = str.slice(0, 20)