tangled
alpha
login
or
join now
ansxor.ca
/
witchsky.app
forked from
jollywhoppers.com/witchsky.app
1
fork
atom
Bluesky app fork with some witchin' additions 💫
1
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
1
import {Dimensions} from 'react-native'
2
2
+
import {isDid} from '@atproto/api'
2
3
4
4
+
import {isValidHandle} from '#/lib/strings/handles'
3
5
import {IS_WEB, IS_WEB_SAFARI} from '#/env'
4
6
5
7
const {height: SCREEN_HEIGHT} = Dimensions.get('window')
···
11
13
: 'https://witchsky.app'
12
14
: __DEV__ && !process.env.JEST_WORKER_ID
13
15
? 'http://localhost:8100'
14
14
-
: 'https://witchsky.app'
16
16
+
: 'https://bsky.app'
15
17
16
18
export const embedPlayerSources = [
17
19
'youtube',
···
464
466
}
465
467
466
468
if (urlp.hostname === 'stream.place') {
467
467
-
return {
468
468
-
type: 'streamplace_stream',
469
469
-
source: 'streamplace',
470
470
-
playerUri: `https://stream.place/embed${urlp.pathname}`,
469
469
+
if (isValidStreamPlaceUrl(urlp)) {
470
470
+
return {
471
471
+
type: 'streamplace_stream',
472
472
+
source: 'streamplace',
473
473
+
playerUri: `https://stream.place/embed${urlp.pathname}`,
474
474
+
}
471
475
}
472
476
}
477
477
+
}
478
478
+
479
479
+
function isValidStreamPlaceUrl(urlp: URL): boolean {
480
480
+
// stream.place URLs should have a path like /did:plc:xxx/... or /handle.bsky.social/...
481
481
+
const pathParts = urlp.pathname.split('/').filter(Boolean)
482
482
+
if (pathParts.length === 0) {
483
483
+
return false
484
484
+
}
485
485
+
486
486
+
// The first part of the path should be either a valid DID or a valid handle
487
487
+
const identifier = pathParts[0]
488
488
+
return isDid(identifier) || isValidHandle(identifier)
473
489
}
474
490
475
491
export function getPlayerAspect({
+4
src/lib/strings/handles.ts
···
7
7
8
8
export const MAX_SERVICE_HANDLE_LENGTH = 18
9
9
10
10
+
export function isValidHandle(handle: string): boolean {
11
11
+
return VALIDATE_REGEX.test(handle)
12
12
+
}
13
13
+
10
14
export function makeValidHandle(str: string): string {
11
15
if (str.length > 20) {
12
16
str = str.slice(0, 20)