fix api test error

This commit is contained in:
root
2026-06-11 23:26:35 -04:00
parent af5b7fda7e
commit 44f59423ec
2 changed files with 5 additions and 3 deletions
@@ -58,7 +58,7 @@ router.post('/validate', async (req, res, next) => {
expiration_date: result.expiration_date,
message: result.message,
next_reminder: result.days_remaining
? new Date(Date.now() + (result.days_remaining - 30) * 86400000).toISOString().split('T')[0]
? new Date(Date.now() + (result.days_remaining - 30) * 86400000).toISOString().split('T')[0] ?? null
: null,
})
} catch (err) {
@@ -58,7 +58,9 @@ export function parseExpirationDate(raw: string | null | undefined): Date | null
const iso = new Date(raw)
if (!isNaN(iso.getTime()) && raw.length >= 10) {
// Ensure we don't accept "2026-06" as valid — need at least YYYY-MM-DD
const parts = raw.split('T')[0].split('-')
const datePart = raw.split('T')[0]
if (!datePart) return null
const parts = datePart.split('-')
if (parts.length === 3) return iso
}
@@ -111,7 +113,7 @@ export function validateLicenseDate(expirationDate: Date | null | undefined): De
const nowMs = now.getTime()
const expMs = expirationDate.getTime()
const daysRemaining = Math.ceil((expMs - nowMs) / MS_PER_DAY)
const expDateStr = expirationDate.toISOString().split('T')[0]
const expDateStr = expirationDate.toISOString().split('T')[0] ?? ''
const minValidityDays = getMinValidityDays()
// Expired