fix(server): invalid exif date string (#2580)

This commit is contained in:
Jason Rasmussen 2023-05-26 22:13:09 -04:00 committed by GitHub
parent f370dc3929
commit e41e0df27e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,13 +116,16 @@ export class MetadataExtractionProcessor {
: {};
const exifToDate = (exifDate: string | ExifDateTime | undefined) => {
if (!exifDate) return null;
if (typeof exifDate === 'string') {
return new Date(exifDate);
if (!exifDate) {
return null;
}
return exifDate.toDate();
const date = typeof exifDate === 'string' ? new Date(exifDate) : exifDate.toDate();
if (isNaN(date.valueOf())) {
return null;
}
return date;
};
const exifTimeZone = (exifDate: string | ExifDateTime | undefined) => {