Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: flakey5 <[email protected]>
  • Loading branch information
flakey5 committed Jan 27, 2025
1 parent 593af38 commit a8af496
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function parseUrl(request: Request): URL | undefined {
}

export function parseConditionalHeaders(headers: Headers): ConditionalHeaders {
const ifModifiedSince = getDateFromHeader(headers.get('if-modified-since'))
const ifModifiedSince = getDateFromHeader(headers.get('if-modified-since'));

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

const ifUnmodifiedSince = getDateFromHeader(headers.get('if-unmodified-since'))
const ifUnmodifiedSince = getDateFromHeader(
headers.get('if-unmodified-since')
);

const range = headers.has('range')
? parseRangeHeader(headers.get('range')!)
Expand Down
17 changes: 10 additions & 7 deletions tests/unit/utils/request.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import assert from 'node:assert';
import { describe, it } from 'node:test';
import { parseConditionalHeaders, parseRangeHeader } from '../../../src/utils/request';
import {
parseConditionalHeaders,
parseRangeHeader,
} from '../../../src/utils/request';

describe('parseRangeHeader', () => {
it('`bytes=0-10`', () => {
Expand Down Expand Up @@ -54,15 +57,15 @@ describe('parseConditionalHeaders', () => {
it('invalid dates', () => {
const headers = new Headers({
'if-modified-since': 'asd',
'if-unmodified-since': 'asd'
'if-unmodified-since': 'asd',
});

assert.deepStrictEqual(parseConditionalHeaders(headers), {
ifMatch: undefined,
ifNoneMatch: undefined,
ifModifiedSince: undefined,
ifUnmodifiedSince: undefined,
range: undefined
})
})
})
range: undefined,
});
});
});

0 comments on commit a8af496

Please sign in to comment.