Skip to content

Commit 363cc9c

Browse files
committed
feat(community): add Supadata document loader
1 parent 6145281 commit 363cc9c

File tree

1 file changed

+14
-1
lines changed
  • libs/langchain-community/src/document_loaders/web

1 file changed

+14
-1
lines changed

libs/langchain-community/src/document_loaders/web/supadata.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,20 @@ export class SupadataLoader extends BaseDocumentLoader {
125125
}
126126

127127
private async loadMetadata(client: any, url: string): Promise<Document> {
128-
const isYoutube = url.includes("youtube.com") || url.includes("youtu.be");
128+
let isYoutube = false;
129+
130+
try {
131+
const hostname = new URL(url).hostname.toLowerCase();
132+
133+
isYoutube =
134+
hostname === "youtube.com" ||
135+
hostname === "www.youtube.com" ||
136+
hostname.endsWith(".youtube.com") ||
137+
hostname === "youtu.be";
138+
} catch {
139+
// If URL parsing fails, treat as non-YouTube
140+
isYoutube = false;
141+
}
129142

130143
let result;
131144
if (isYoutube && client.youtube?.video) {

0 commit comments

Comments
 (0)