File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,15 @@ export function parseUrl(request: Request): URL | undefined {
3030}
3131
3232export function parseConditionalHeaders ( headers : Headers ) : ConditionalHeaders {
33- const ifModifiedSince = headers . has ( 'if-modified-since' )
33+ let ifModifiedSince = headers . has ( 'if-modified-since' )
3434 ? new Date ( headers . get ( 'if-modified-since' ) ! )
3535 : undefined ;
3636
3737 if ( ifModifiedSince instanceof Date ) {
3838 ifModifiedSince . setSeconds ( ifModifiedSince . getSeconds ( ) + 1 ) ;
39+ } else {
40+ // Invalid date
41+ ifModifiedSince = undefined ;
3942 }
4043
4144 const ifMatch = headers . has ( 'if-match' )
@@ -46,10 +49,15 @@ export function parseConditionalHeaders(headers: Headers): ConditionalHeaders {
4649 ? headers . get ( 'if-none-match' ) ! . replaceAll ( '"' , '' )
4750 : undefined ;
4851
49- const ifUnmodifiedSince = headers . has ( 'if-unmodified-since' )
52+ let ifUnmodifiedSince = headers . has ( 'if-unmodified-since' )
5053 ? new Date ( headers . get ( 'if-unmodified-since' ) ! )
5154 : undefined ;
5255
56+ if ( ! ( ifUnmodifiedSince instanceof Date ) ) {
57+ // Invalid date
58+ ifUnmodifiedSince = undefined ;
59+ }
60+
5361 const range = headers . has ( 'range' )
5462 ? parseRangeHeader ( headers . get ( 'range' ) ! )
5563 : undefined ;
You can’t perform that action at this time.
0 commit comments