Skip to content
Closed
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
2 changes: 1 addition & 1 deletion docs/guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Assets referenced by HTML elements such as `<script type="module" src>` and `<li
- `<video src>` and `<video poster>`
- `<meta content>`
- Only if `name` attribute matches `msapplication-tileimage`, `msapplication-square70x70logo`, `msapplication-square150x150logo`, `msapplication-wide310x150logo`, `msapplication-square310x310logo`, `msapplication-config`, or `twitter:image`
- Or only if `property` attribute matches `og:image`, `og:image:url`, `og:image:secure_url`, `og:audio`, `og:audio:secure_url`, `og:video`, or `og:video:secure_url`
- Or only if `property` attribute matches `og:image`, `og:image:url`, `og:image:secure_url`, `og:audio`, `og:audio:url`, `og:audio:secure_url`, `og:video`, `og:video:url`, or `og:video:secure_url`

```html {4-5,8-9}
<!doctype html>
Expand Down
16 changes: 16 additions & 0 deletions packages/vite/src/node/__tests__/assetSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ describe('getNodeAssetAttributes', () => {
expect(attrs[0]).toHaveProperty('value', 'image.jpg')
})

test.each([
'og:image:url',
'og:audio:url',
'og:video:url',
'og:image:secure_url',
'og:audio:secure_url',
'og:video:secure_url',
])('handles meta property %s', (property) => {
const node = getNode(`<meta property="${property}" content="media.mp4">`)
const attrs = getNodeAssetAttributes(node)
expect(attrs).toHaveLength(1)
expect(attrs[0]).toHaveProperty('type', 'src')
expect(attrs[0]).toHaveProperty('key', 'content')
expect(attrs[0]).toHaveProperty('value', 'media.mp4')
})

test('does not handle meta with unknown name', () => {
const node = getNode('<meta name="unknown" content="image.jpg">')
const attrs = getNodeAssetAttributes(node)
Expand Down
2 changes: 2 additions & 0 deletions packages/vite/src/node/assetSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ const ALLOWED_META_PROPERTY = [
'og:image:url',
'og:image:secure_url',
'og:audio',
'og:audio:url',
'og:audio:secure_url',
'og:video',
'og:video:url',
'og:video:secure_url',
]

Expand Down
Loading