From 4b91f67e154ff93c46463b046cccd438307c317f Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 2 Aug 2026 17:34:57 -0500 Subject: [PATCH] fix: enforce valid Open Graph author URLs --- scripts/verify-build.mjs | 17 ++++++++++++++++- src/layouts/Base.astro | 6 +++--- src/layouts/Post.astro | 1 - 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/verify-build.mjs b/scripts/verify-build.mjs index 988c211..e1e12d0 100644 --- a/scripts/verify-build.mjs +++ b/scripts/verify-build.mjs @@ -184,7 +184,22 @@ for (const post of postPages) { ); requireSingleMeta(post.html, post.label, 'og:type', 'article'); const publishedTime = requireSingleMeta(post.html, post.label, 'article:published_time'); - requireSingleMeta(post.html, post.label, 'article:author'); + const articleAuthors = metaTags(post.html, 'property', 'article:author'); + for (const articleAuthor of articleAuthors) { + const authorUrl = attribute(articleAuthor, 'content'); + assert.ok(authorUrl?.trim(), `${post.label} article:author must not be empty`); + let parsedAuthorUrl; + assert.doesNotThrow( + () => { + parsedAuthorUrl = new URL(authorUrl); + }, + `${post.label} article:author must be a valid absolute URL`, + ); + assert.ok( + ['https:', 'http:'].includes(parsedAuthorUrl.protocol), + `${post.label} article:author must use HTTP or HTTPS`, + ); + } requireValidDate( attribute(publishedTime, 'content'), `${post.label} article:published_time content`, diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index d2e9c43..ff4e33b 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -14,7 +14,7 @@ interface Props { robots?: string; publishedTime?: Date; updatedTime?: Date; - author?: string; + authorUrl?: string; tags?: string[]; structuredData?: StructuredData; } @@ -27,7 +27,7 @@ const { robots = 'index, follow', publishedTime, updatedTime, - author, + authorUrl, tags, structuredData, } = Astro.props; @@ -62,7 +62,7 @@ const serializedStructuredData = structuredData <> {publishedTime && } {updatedTime && } - {author && } + {authorUrl && } {tags?.map((tag) => )} ) diff --git a/src/layouts/Post.astro b/src/layouts/Post.astro index 250cbe3..682223b 100644 --- a/src/layouts/Post.astro +++ b/src/layouts/Post.astro @@ -53,7 +53,6 @@ const structuredData = { ogType="article" publishedTime={pubDate} updatedTime={updatedDate ?? pubDate} - author={author} tags={tags} structuredData={structuredData} >