File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -29,15 +29,18 @@ export function parseUrl(request: Request): URL | undefined {
2929 return url ;
3030}
3131
32+ export function isValidDate ( date ?: Date ) : boolean {
33+ return date instanceof Date && ! isNaN ( date ) ;
34+ }
35+
3236export function parseConditionalHeaders ( headers : Headers ) : ConditionalHeaders {
3337 let ifModifiedSince = headers . has ( 'if-modified-since' )
3438 ? new Date ( headers . get ( 'if-modified-since' ) ! )
3539 : undefined ;
3640
37- if ( ifModifiedSince instanceof Date ) {
41+ if ( isValidDate ( ifModifiedSince ) ) {
3842 ifModifiedSince . setSeconds ( ifModifiedSince . getSeconds ( ) + 1 ) ;
3943 } else {
40- // Invalid date
4144 ifModifiedSince = undefined ;
4245 }
4346
@@ -53,8 +56,7 @@ export function parseConditionalHeaders(headers: Headers): ConditionalHeaders {
5356 ? new Date ( headers . get ( 'if-unmodified-since' ) ! )
5457 : undefined ;
5558
56- if ( ! ( ifUnmodifiedSince instanceof Date ) ) {
57- // Invalid date
59+ if ( ! isValidDate ( ifUnmodifiedSince ) ) {
5860 ifUnmodifiedSince = undefined ;
5961 }
6062
You can’t perform that action at this time.
0 commit comments