Skip to content

Commit ffc10c3

Browse files
committed
fix bug with og tags
1 parent ba353ad commit ffc10c3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/common/OGTags.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@ export async function getOGTags(url: string): GetOGTagsReturn {
9595
const metaTags = root.querySelectorAll('head meta');
9696

9797
const filteredOGTags = metaTags.filter((el) => {
98-
const isOG = el.attributes.name?.startsWith('og:');
99-
const isValidField = mapper.has(el.attributes.name?.split('og:')?.[1]);
98+
const name = el.attributes.name?.split('og:')?.[1] || el.attributes.name;
99+
const isValidField = mapper.has(name);
100100
const hasContent = el.attributes.content;
101-
return isOG && isValidField && hasContent;
101+
return isValidField && hasContent;
102102
});
103103

104-
const entries = filteredOGTags.map((el) => [mapper.get(el.attributes.name.split('og:')[1]), el.attributes.content.substring(0, 1000)]);
104+
const entries = filteredOGTags.map((el) => {
105+
const name = el.attributes.name?.split('og:')?.[1] || el.attributes.name;
106+
107+
return [mapper.get(name), el.attributes.content.substring(0, 1000)];
108+
});
105109
if (!youtubeWatchCode && !entries.length) return false;
106110
let object = Object.fromEntries(entries || []);
107111

0 commit comments

Comments
 (0)