Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/extractors/youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,15 @@ export class YoutubeExtractor extends BaseExtractor {
}

private getVideoId(): string {
const url = new URL(this.url);
if (url.hostname === 'youtu.be') {
return url.pathname.slice(1);
try {
const url = new URL(this.url);
if (url.hostname === 'youtu.be') {
return url.pathname.slice(1);
}
return new URLSearchParams(url.search).get('v') || '';
} catch {
return '';
}
return new URLSearchParams(url.search).get('v') || '';
}

/**
Expand Down