Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ export function parseUrl(request: Request): URL | undefined {
}

export function parseConditionalHeaders(headers: Headers): ConditionalHeaders {
const ifModifiedSince = headers.has('if-modified-since')
let ifModifiedSince = headers.has('if-modified-since')
? new Date(headers.get('if-modified-since')!)
: undefined;

if (ifModifiedSince instanceof Date) {
ifModifiedSince.setSeconds(ifModifiedSince.getSeconds() + 1);
} else {
// Invalid date
ifModifiedSince = undefined;
}

const ifMatch = headers.has('if-match')
Expand All @@ -46,10 +49,15 @@ export function parseConditionalHeaders(headers: Headers): ConditionalHeaders {
? headers.get('if-none-match')!.replaceAll('"', '')
: undefined;

const ifUnmodifiedSince = headers.has('if-unmodified-since')
let ifUnmodifiedSince = headers.has('if-unmodified-since')
? new Date(headers.get('if-unmodified-since')!)
: undefined;

if (!(ifUnmodifiedSince instanceof Date)) {
// Invalid date
ifUnmodifiedSince = undefined;
}

const range = headers.has('range')
? parseRangeHeader(headers.get('range')!)
: undefined;
Expand Down
Loading