Skip to content

Commit 4bd7405

Browse files
committedDec 23, 2024·
fix: handle malformed og image paths
Fixes #294
1 parent bbf3fac commit 4bd7405

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/runtime/app/utils/plugins.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ export function ogImageCanonicalUrls(nuxtApp: NuxtApp) {
4949

5050
for (const tag of ctx.tags) {
5151
if (tag.tag === 'meta' && (tag.props.property === 'og:image' || ['twitter:image:src', 'twitter:image'].includes(tag.props.name))) {
52+
if (!tag.props.content) {
53+
tag.props = {} // equivalent to removing
54+
continue
55+
}
5256
// looking for:
5357
// property og:image
5458
// property twitter:image:src
55-
if (!tag.props.content.startsWith('https')) {
59+
if (!tag.props.content?.startsWith('https')) {
5660
await nuxtApp.runWithContext(() => {
5761
tag.props.content = toValue(withSiteUrl(tag.props.content, {
5862
withBase: true,

0 commit comments

Comments
 (0)
Please sign in to comment.