mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 04:45:08 +03:00
Apply suggestions from code review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
809990e8ea
commit
065ec19daa
2 files changed
+10
-2
No files matched your search
+6
-1
@@ -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[] {
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in new issue
Block a user