Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add type markup property for video/audio #168

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ const addBody = ({ url, headers, html }) => {
if (isMime(contentType, 'image')) {
element = `<img src="${url}"></img>`
} else if (isMime(contentType, 'video')) {
element = `<video src="${url}"></video>`
element = `<video><source src="${url}" type="${contentType}"></source></video>`
} else if (isMime(contentType, 'audio')) {
element = `<audio src="${url}"></audio>`
element = `<audio><source src="${url}" type="${contentType}"></source></audio>`
} else if (mimeExtension(contentType) === 'json') {
element = `<pre>${html}</pre>`
}
Expand Down
8 changes: 6 additions & 2 deletions test/html/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ Generated by [AVA](https://avajs.dev).
<meta property="og:site_name" content="audiovideoweb.com">␊
<link rel="canonical" href="http://websrvr90va.audiovideoweb.com/va90web25003/companions/Foundations%20of%20Rock/13.01.mp3">␊
</head>␊
<body><audio src="http://websrvr90va.audiovideoweb.com/va90web25003/companions/Foundations%20of%20Rock/13.01.mp3"></audio></body>␊
<body><audio>␊
<source src="http://websrvr90va.audiovideoweb.com/va90web25003/companions/Foundations%20of%20Rock/13.01.mp3" type="audio/mp3">␊
</audio></body>␊
</html>`

## add video markup
Expand All @@ -103,7 +105,9 @@ Generated by [AVA](https://avajs.dev).
<meta property="og:site_name" content="sample-videos.com">␊
<link rel="canonical" href="https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4">␊
</head>␊
<body><video src="https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4"></video></body>␊
<body><video>␊
<source src="https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">␊
</video></body>␊
</html>`

## '`rewriteCssUrls` don't modify html markup
Expand Down
Binary file modified test/html/snapshots/index.js.snap
Binary file not shown.
8 changes: 6 additions & 2 deletions test/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Generated by [AVA](https://avajs.dev).
<meta name="date" content="{DATE}">␊
<link rel="canonical" href="https://audiodemos.github.io/vctk_set0/embedadapt_100sample.wav">␊
</head>␊
<body><audio src="https://audiodemos.github.io/vctk_set0/embedadapt_100sample.wav"></audio></body>␊
<body><audio>␊
<source src="https://audiodemos.github.io/vctk_set0/embedadapt_100sample.wav" type="audio/wav">␊
</audio></body>␊
</html>`

## from image URL
Expand Down Expand Up @@ -45,7 +47,9 @@ Generated by [AVA](https://avajs.dev).
<meta name="date" content="{DATE}">␊
<link rel="canonical" href="http://techslides.com/demos/sample-videos/small.mp4">␊
</head>␊
<body><video src="http://techslides.com/demos/sample-videos/small.mp4"></video></body>␊
<body><video>␊
<source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">␊
</video></body>␊
</html>`

## from bad SSL URL
Expand Down
Binary file modified test/snapshots/index.js.snap
Binary file not shown.