Skip to content

Commit 3d22c51

Browse files
committed
chore: lint
1 parent c429fb4 commit 3d22c51

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

Diff for: .playground/pages/prerender-video.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
<source
3131
src="https://archive.org/download/DuckAndCover_185/CivilDefenseFilm-DuckAndCoverColdWarNuclearPropaganda_512kb.mp4"
3232
type="video/mp4"
33-
/>
33+
>
3434
<source
3535
src="https://archive.org/download/DuckAndCover_185/CivilDefenseFilm-DuckAndCoverColdWarNuclearPropaganda.avi"
3636
type="video/x-msvideo"
37-
/>
37+
>
3838
Sorry, your browser doesn't support embedded videos, but don't worry, you
3939
can
4040
<a href="https://archive.org/details/DuckAndCover_185">download it</a>

Diff for: src/util/extractSitemapMetaFromHtml.ts

+14-15
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ export function extractSitemapMetaFromHtml(html: string, options?: { images?: bo
3838
if (mainMatch?.[1] && mainMatch[1].includes('<video')) {
3939
// Extract video src & child source attributes using regex on the HTML
4040
const videoRegex = /<video[^>]*>([\s\S]*?)<\/video>/g
41-
const videoAttrRegex = /<video[^>]*\s+src="([^"]+)"(?:[^>]*\s+poster="([^"]+)")?/
42-
const videoPosterRegex = /<video[^>]*\s+poster="([^"]+)"/
43-
const videoTitleRegex = /<video[^>]*\s+data-title="([^"]+)"/
44-
const videoDescriptionRegex = /<video[^>]*\s+data-description="([^"]+)"/
45-
const sourceRegex = /<source[^>]*\s+src="([^"]+)"/g
41+
const videoAttrRegex = /<video[^>]*\ssrc="([^"]+)"(?:[^>]*\sposter="([^"]+)")?/
42+
const videoPosterRegex = /<video[^>]*\sposter="([^"]+)"/
43+
const videoTitleRegex = /<video[^>]*\sdata-title="([^"]+)"/
44+
const videoDescriptionRegex = /<video[^>]*\sdata-description="([^"]+)"/
45+
const sourceRegex = /<source[^>]*\ssrc="([^"]+)"/g
4646

47-
let videoMatch;
47+
let videoMatch
4848
while ((videoMatch = videoRegex.exec(mainMatch[1])) !== null) {
4949
const videoContent = videoMatch[1]
5050
const videoTag = videoMatch[0]
5151

5252
// Extract src and poster attributes from the <video> tag
53-
const videoAttrMatch = videoAttrRegex.exec(videoTag);
53+
const videoAttrMatch = videoAttrRegex.exec(videoTag)
5454
const videoSrc = videoAttrMatch ? videoAttrMatch[1] : ''
5555
const poster = (videoPosterRegex.exec(videoTag) || [])[1] || ''
5656
const title = (videoTitleRegex.exec(videoTag) || [])[1] || ''
5757
const description = (videoDescriptionRegex.exec(videoTag) || [])[1] || ''
5858

5959
// Extract src attributes from child <source> elements
60-
const sources = [];
61-
let sourceMatch;
60+
const sources = []
61+
let sourceMatch
6262
while ((sourceMatch = sourceRegex.exec(videoContent)) !== null) {
6363
sources.push({
6464
src: sourceMatch[1],
@@ -67,7 +67,7 @@ export function extractSitemapMetaFromHtml(html: string, options?: { images?: bo
6767
description: description,
6868
})
6969
}
70-
70+
7171
// Add video with src attribute
7272
if (videoSrc) {
7373
videos.push({
@@ -88,18 +88,17 @@ export function extractSitemapMetaFromHtml(html: string, options?: { images?: bo
8888

8989
// Map videos to payload
9090
if (videos.length > 0) {
91-
payload.videos = videos.map(video =>
91+
payload.videos = videos.map(video =>
9292
({
9393
content_loc: video.src,
9494
thumbnail_loc: video.poster,
9595
title: video.title,
96-
description: video.description
97-
}) as VideoEntry
98-
);
96+
description: video.description,
97+
}) as VideoEntry,
98+
)
9999
}
100100
}
101101

102-
103102
if (options?.lastmod) {
104103
// let's extract the lastmod from the html using the following tags:
105104
const articleModifiedTime = html.match(/<meta[^>]+property="article:modified_time"[^>]+content="([^"]+)"/)?.[1]

Diff for: test/unit/extractSitemapMetaFromHtml.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ describe('extractSitemapMetaFromHtml', () => {
214214
},
215215
],
216216
}
217-
`);
217+
`)
218218

219219
// Test case 4 - Multiple discoverable video sources
220-
const html4 = `${mainTag}${discoverableVideoSourcesWithPosterHTML}${mainClosingTag}`;
221-
const testcase4 = extractSitemapMetaFromHtml(html4);
220+
const html4 = `${mainTag}${discoverableVideoSourcesWithPosterHTML}${mainClosingTag}`
221+
const testcase4 = extractSitemapMetaFromHtml(html4)
222222

223223
expect(testcase4).toMatchInlineSnapshot(`
224224
{

0 commit comments

Comments
 (0)