Skip to content

Commit

Permalink
availability page handle youtu.be links
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Oct 28, 2024
1 parent 9db7796 commit 8728048
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion testpage/poster-image-availability.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@

$('form').on('submit', (e) => {
const value = $('input').value;
const videoid = value.length < 20 ? value : new URL(value).searchParams.get('v');
let videoid = value.length < 20 ? value : new URL(value).searchParams.get('v');
if (!videoid) {
const u = URL.parse(value);
if (u.host === 'youtu.be') {
videoid = u.pathname.slice(1);
}
}
$('input').value = videoid;
});

Expand Down

0 comments on commit 8728048

Please sign in to comment.