File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments