Skip to content

fix: handle invalid URL in YouTube getVideoId()#171

Open
0xDaizz wants to merge 1 commit intokepano:mainfrom
0xDaizz:fix/youtube-url-validation
Open

fix: handle invalid URL in YouTube getVideoId()#171
0xDaizz wants to merge 1 commit intokepano:mainfrom
0xDaizz:fix/youtube-url-validation

Conversation

@0xDaizz
Copy link
Contributor

@0xDaizz 0xDaizz commented Mar 14, 2026

Summary

  • Added try-catch around new URL(this.url) in getVideoId() to prevent TypeError: Invalid URL when this.url is undefined or malformed
  • Returns empty string on failure instead of throwing, consistent with the existing || '' fallback

Motivation

When the YouTube extractor receives an undefined or invalid URL, new URL(this.url) throws an unhandled TypeError: Invalid URL (input: 'undefined') to stderr. This happens for certain YouTube videos where the URL isn't properly passed through the extractor pipeline.

Note: PR #51 fixed a related but different issue (youtu.be short URL parsing). This fix addresses the case where this.url itself is undefined/invalid, which still occurs in v0.13.0.

Test plan

  • YouTube video with valid URL → works as before
  • YouTube extractor with undefined URL → returns empty string, no TypeError

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant