Bluesky app fork with some witchin' additions 💫

fix YouTube and improve Streamplace embeds

xan.lol b247469e cccfbd0b

verified
+25 -5
+21 -5
src/lib/strings/embed-player.ts
··· 1 1 import {Dimensions} from 'react-native' 2 + import {isDid} from '@atproto/api' 2 3 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 - : 'https://witchsky.app' 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 - return { 468 - type: 'streamplace_stream', 469 - source: 'streamplace', 470 - playerUri: `https://stream.place/embed${urlp.pathname}`, 469 + if (isValidStreamPlaceUrl(urlp)) { 470 + return { 471 + type: 'streamplace_stream', 472 + source: 'streamplace', 473 + playerUri: `https://stream.place/embed${urlp.pathname}`, 474 + } 471 475 } 472 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) 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 + export function isValidHandle(handle: string): boolean { 11 + return VALIDATE_REGEX.test(handle) 12 + } 13 + 10 14 export function makeValidHandle(str: string): string { 11 15 if (str.length > 20) { 12 16 str = str.slice(0, 20)