diff options
Diffstat (limited to 'src/lib/strings')
-rw-r--r-- | src/lib/strings/embed-player.ts | 13 | ||||
-rw-r--r-- | src/lib/strings/password.ts | 19 |
2 files changed, 27 insertions, 5 deletions
diff --git a/src/lib/strings/embed-player.ts b/src/lib/strings/embed-player.ts index 3270b6f07..21a575b91 100644 --- a/src/lib/strings/embed-player.ts +++ b/src/lib/strings/embed-player.ts @@ -1,4 +1,5 @@ -import {Dimensions, Platform} from 'react-native' +import {Dimensions} from 'react-native' +import {isWeb} from 'platform/detection' const {height: SCREEN_HEIGHT} = Dimensions.get('window') export const embedPlayerSources = [ @@ -73,7 +74,7 @@ export function parseEmbedPlayerFromUrl( return { type: 'youtube_video', source: 'youtube', - playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`, + playerUri: `https://bsky.app/iframe/youtube.html?videoId=${videoId}&start=${seek}`, } } } @@ -92,7 +93,7 @@ export function parseEmbedPlayerFromUrl( type: page === 'shorts' ? 'youtube_short' : 'youtube_video', source: page === 'shorts' ? 'youtubeShorts' : 'youtube', hideDetails: page === 'shorts' ? true : undefined, - playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`, + playerUri: `https://bsky.app/iframe/youtube.html?videoId=${videoId}&start=${seek}`, } } } @@ -103,8 +104,10 @@ export function parseEmbedPlayerFromUrl( urlp.hostname === 'www.twitch.tv' || urlp.hostname === 'm.twitch.tv' ) { - const parent = - Platform.OS === 'web' ? window.location.hostname : 'localhost' + const parent = isWeb + ? // @ts-ignore only for web + window.location.hostname + : 'localhost' const [_, channelOrVideo, clipOrId, id] = urlp.pathname.split('/') diff --git a/src/lib/strings/password.ts b/src/lib/strings/password.ts new file mode 100644 index 000000000..e7735b90e --- /dev/null +++ b/src/lib/strings/password.ts @@ -0,0 +1,19 @@ +// Regex for base32 string for testing reset code +const RESET_CODE_REGEX = /^[A-Z2-7]{5}-[A-Z2-7]{5}$/ + +export function checkAndFormatResetCode(code: string): string | false { + // Trim the reset code + let fixed = code.trim().toUpperCase() + + // Add a dash if needed + if (fixed.length === 10) { + fixed = `${fixed.slice(0, 5)}-${fixed.slice(5, 10)}` + } + + // Check that it is a valid format + if (!RESET_CODE_REGEX.test(fixed)) { + return false + } + + return fixed +} |