Merge pull request #176 from Osamaali313/fix/youtube-embed-url

fix(baoyu-fetch): parse YouTube /embed/ URLs in parseYouTubeVideoId
This commit is contained in:
Jim Liu 宝玉
2026-06-10 17:56:23 -05:00
committed by GitHub
2 changed files with 9 additions and 0 deletions
@@ -19,6 +19,10 @@ describe("parseYouTubeVideoId", () => {
test("parses shorts URLs", () => {
expect(parseYouTubeVideoId(new URL("https://www.youtube.com/shorts/abc123"))).toBe("abc123");
});
test("parses embed URLs", () => {
expect(parseYouTubeVideoId(new URL("https://www.youtube.com/embed/abc123"))).toBe("abc123");
});
});
describe("parseYouTubeDescriptionChapters", () => {
@@ -52,6 +52,11 @@ export function parseYouTubeVideoId(url: URL): string | null {
return liveMatch[1];
}
const embedMatch = url.pathname.match(/^\/embed\/([^/?#]+)/);
if (embedMatch) {
return embedMatch[1];
}
return null;
}