diff options
Diffstat (limited to 'src/lib/strings/url-helpers.ts')
-rw-r--r-- | src/lib/strings/url-helpers.ts | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts index e9bf4111d..8a71718c8 100644 --- a/src/lib/strings/url-helpers.ts +++ b/src/lib/strings/url-helpers.ts @@ -139,35 +139,6 @@ export function feedUriToHref(url: string): string { } } -export function getYoutubeVideoId(link: string): string | undefined { - let url - try { - url = new URL(link) - } catch (e) { - return undefined - } - - if ( - url.hostname !== 'www.youtube.com' && - url.hostname !== 'youtube.com' && - url.hostname !== 'youtu.be' - ) { - return undefined - } - if (url.hostname === 'youtu.be') { - const videoId = url.pathname.split('/')[1] - if (!videoId) { - return undefined - } - return videoId - } - const videoId = url.searchParams.get('v') as string - if (!videoId) { - return undefined - } - return videoId -} - /** * Checks if the label in the post text matches the host of the link facet. * |