diff --git a/apps/www/lib/go.ts b/apps/www/lib/go.ts index dce09d01cdb..9a14bbc6188 100644 --- a/apps/www/lib/go.ts +++ b/apps/www/lib/go.ts @@ -3,7 +3,12 @@ import { goPageSchema, type GoPage } from '@/types/go' function isExpired(page: { expiresAt?: string }): boolean { if (!page.expiresAt) return false - return new Date(page.expiresAt) < new Date() + const [year, month, day] = page.expiresAt.split('-').map(Number) + if (![year, month, day].every(Number.isInteger)) { + throw new Error(`Invalid expiresAt value: "${page.expiresAt}"`) + } + const expiresAtEndOfDayUtc = Date.UTC(year, month - 1, day, 23, 59, 59, 999) + return Date.now() > expiresAtEndOfDayUtc } export function getAllGoPages(): GoPage[] { diff --git a/packages/marketing/src/go/schemas.ts b/packages/marketing/src/go/schemas.ts index 20eb7ab3c99..b1ab549f02d 100644 --- a/packages/marketing/src/go/schemas.ts +++ b/packages/marketing/src/go/schemas.ts @@ -333,7 +333,10 @@ const goPageBaseSchema = z.object({ sections: z.array(goSectionSchema).optional(), publishedAt: z.string().optional(), /** ISO 8601 date (YYYY-MM-DD) after which the page should return a 404. */ - expiresAt: z.string().optional(), + expiresAt: z + .string() + .regex(/^\d{4}-\d{2}-\d{2}$/, 'expiresAt must be YYYY-MM-DD') + .optional(), }) export const leadGenPageSchema = goPageBaseSchema.extend({