fix api test error
This commit is contained in:
@@ -58,7 +58,7 @@ router.post('/validate', async (req, res, next) => {
|
|||||||
expiration_date: result.expiration_date,
|
expiration_date: result.expiration_date,
|
||||||
message: result.message,
|
message: result.message,
|
||||||
next_reminder: result.days_remaining
|
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,
|
: null,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ export function parseExpirationDate(raw: string | null | undefined): Date | null
|
|||||||
const iso = new Date(raw)
|
const iso = new Date(raw)
|
||||||
if (!isNaN(iso.getTime()) && raw.length >= 10) {
|
if (!isNaN(iso.getTime()) && raw.length >= 10) {
|
||||||
// Ensure we don't accept "2026-06" as valid — need at least YYYY-MM-DD
|
// 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
|
if (parts.length === 3) return iso
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +113,7 @@ export function validateLicenseDate(expirationDate: Date | null | undefined): De
|
|||||||
const nowMs = now.getTime()
|
const nowMs = now.getTime()
|
||||||
const expMs = expirationDate.getTime()
|
const expMs = expirationDate.getTime()
|
||||||
const daysRemaining = Math.ceil((expMs - nowMs) / MS_PER_DAY)
|
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()
|
const minValidityDays = getMinValidityDays()
|
||||||
|
|
||||||
// Expired
|
// Expired
|
||||||
|
|||||||
Reference in New Issue
Block a user