From 848af19cf96c3d42476e9d0878ccc40c8162f10d Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Tue, 5 Nov 2024 11:07:15 +0100 Subject: [PATCH] Improve validation of Date object in `getInitialDateFromUrl` The `isDate` function only verifies if a value is a `Date` object without checking its validity. Since `new Date()` returns a `Date` object even for invalid date strings (`initialDateString`), this adjustment ensures that only valid dates pass the check. --- src/apps/opening-hours-editor/helper.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/apps/opening-hours-editor/helper.ts b/src/apps/opening-hours-editor/helper.ts index 4b293b85f5..99936dfc21 100644 --- a/src/apps/opening-hours-editor/helper.ts +++ b/src/apps/opening-hours-editor/helper.ts @@ -1,5 +1,4 @@ import dayjs from "dayjs"; -import { isDate } from "lodash"; import { EventInput } from "@fullcalendar/core"; import { EventImpl } from "@fullcalendar/core/internal"; import { @@ -185,7 +184,7 @@ export const getInitialDateFromUrl = (): Date | null => { } const date = new Date(initialDateString); - if (isDate(date)) { + if (!Number.isNaN(date.getTime())) { return date; } // eslint-disable-next-line no-console