fix: sanitize invalid map timestamps
This commit is contained in:
parent
c9e5ece185
commit
d1110eca38
1 changed files with 4 additions and 2 deletions
|
|
@ -38,9 +38,11 @@ export function parseTimestamp(timestamp: string | number | Date | undefined): n
|
|||
if (typeof timestamp === "number") {
|
||||
return timestamp;
|
||||
} else if (typeof timestamp === "string") {
|
||||
return new Date(timestamp).getTime();
|
||||
const parsed = new Date(timestamp).getTime();
|
||||
return Number.isNaN(parsed) ? Date.now() : parsed;
|
||||
} else if (timestamp instanceof Date) {
|
||||
return timestamp.getTime();
|
||||
const parsed = timestamp.getTime();
|
||||
return Number.isNaN(parsed) ? Date.now() : parsed;
|
||||
}
|
||||
return Date.now();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue