mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-08-01 14:49:47 +08:00
Merge pull request #176 from Osamaali313/fix/youtube-embed-url
fix(baoyu-fetch): parse YouTube /embed/ URLs in parseYouTubeVideoId
This commit is contained in:
@@ -19,6 +19,10 @@ describe("parseYouTubeVideoId", () => {
|
|||||||
test("parses shorts URLs", () => {
|
test("parses shorts URLs", () => {
|
||||||
expect(parseYouTubeVideoId(new URL("https://www.youtube.com/shorts/abc123"))).toBe("abc123");
|
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", () => {
|
describe("parseYouTubeDescriptionChapters", () => {
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ export function parseYouTubeVideoId(url: URL): string | null {
|
|||||||
return liveMatch[1];
|
return liveMatch[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const embedMatch = url.pathname.match(/^\/embed\/([^/?#]+)/);
|
||||||
|
if (embedMatch) {
|
||||||
|
return embedMatch[1];
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user