@@ -38,27 +38,27 @@ export function extractSitemapMetaFromHtml(html: string, options?: { images?: bo
38
38
if ( mainMatch ?. [ 1 ] && mainMatch [ 1 ] . includes ( '<video' ) ) {
39
39
// Extract video src & child source attributes using regex on the HTML
40
40
const videoRegex = / < v i d e o [ ^ > ] * > ( [ \s \S ] * ?) < \/ v i d e o > / g
41
- const videoAttrRegex = / < v i d e o [ ^ > ] * \s + s r c = " ( [ ^ " ] + ) " (?: [ ^ > ] * \s + p o s t e r = " ( [ ^ " ] + ) " ) ? /
42
- const videoPosterRegex = / < v i d e o [ ^ > ] * \s + p o s t e r = " ( [ ^ " ] + ) " /
43
- const videoTitleRegex = / < v i d e o [ ^ > ] * \s + d a t a - t i t l e = " ( [ ^ " ] + ) " /
44
- const videoDescriptionRegex = / < v i d e o [ ^ > ] * \s + d a t a - d e s c r i p t i o n = " ( [ ^ " ] + ) " /
45
- const sourceRegex = / < s o u r c e [ ^ > ] * \s + s r c = " ( [ ^ " ] + ) " / g
41
+ const videoAttrRegex = / < v i d e o [ ^ > ] * \s s r c = " ( [ ^ " ] + ) " (?: [ ^ > ] * \s p o s t e r = " ( [ ^ " ] + ) " ) ? /
42
+ const videoPosterRegex = / < v i d e o [ ^ > ] * \s p o s t e r = " ( [ ^ " ] + ) " /
43
+ const videoTitleRegex = / < v i d e o [ ^ > ] * \s d a t a - t i t l e = " ( [ ^ " ] + ) " /
44
+ const videoDescriptionRegex = / < v i d e o [ ^ > ] * \s d a t a - d e s c r i p t i o n = " ( [ ^ " ] + ) " /
45
+ const sourceRegex = / < s o u r c e [ ^ > ] * \s s r c = " ( [ ^ " ] + ) " / g
46
46
47
- let videoMatch ;
47
+ let videoMatch
48
48
while ( ( videoMatch = videoRegex . exec ( mainMatch [ 1 ] ) ) !== null ) {
49
49
const videoContent = videoMatch [ 1 ]
50
50
const videoTag = videoMatch [ 0 ]
51
51
52
52
// Extract src and poster attributes from the <video> tag
53
- const videoAttrMatch = videoAttrRegex . exec ( videoTag ) ;
53
+ const videoAttrMatch = videoAttrRegex . exec ( videoTag )
54
54
const videoSrc = videoAttrMatch ? videoAttrMatch [ 1 ] : ''
55
55
const poster = ( videoPosterRegex . exec ( videoTag ) || [ ] ) [ 1 ] || ''
56
56
const title = ( videoTitleRegex . exec ( videoTag ) || [ ] ) [ 1 ] || ''
57
57
const description = ( videoDescriptionRegex . exec ( videoTag ) || [ ] ) [ 1 ] || ''
58
58
59
59
// Extract src attributes from child <source> elements
60
- const sources = [ ] ;
61
- let sourceMatch ;
60
+ const sources = [ ]
61
+ let sourceMatch
62
62
while ( ( sourceMatch = sourceRegex . exec ( videoContent ) ) !== null ) {
63
63
sources . push ( {
64
64
src : sourceMatch [ 1 ] ,
@@ -67,7 +67,7 @@ export function extractSitemapMetaFromHtml(html: string, options?: { images?: bo
67
67
description : description ,
68
68
} )
69
69
}
70
-
70
+
71
71
// Add video with src attribute
72
72
if ( videoSrc ) {
73
73
videos . push ( {
@@ -88,18 +88,17 @@ export function extractSitemapMetaFromHtml(html: string, options?: { images?: bo
88
88
89
89
// Map videos to payload
90
90
if ( videos . length > 0 ) {
91
- payload . videos = videos . map ( video =>
91
+ payload . videos = videos . map ( video =>
92
92
( {
93
93
content_loc : video . src ,
94
94
thumbnail_loc : video . poster ,
95
95
title : video . title ,
96
- description : video . description
97
- } ) as VideoEntry
98
- ) ;
96
+ description : video . description ,
97
+ } ) as VideoEntry ,
98
+ )
99
99
}
100
100
}
101
101
102
-
103
102
if ( options ?. lastmod ) {
104
103
// let's extract the lastmod from the html using the following tags:
105
104
const articleModifiedTime = html . match ( / < m e t a [ ^ > ] + p r o p e r t y = " a r t i c l e : m o d i f i e d _ t i m e " [ ^ > ] + c o n t e n t = " ( [ ^ " ] + ) " / ) ?. [ 1 ]
0 commit comments