Skip to content

Commit

Permalink
fix(transform): remove unnecessary requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Mar 25, 2023
1 parent afc8d4e commit 43900d8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ response will not [convert](#convert).
- Response status code is `200`
- Response does not include `Content-Range` header
- Response does not include `Accept-Ranges` header or its value is not `none`
- Response includes `Content-Type` header
- Response body is readable

Note that if there is an `If-Range` header, do nothing.
Expand Down
7 changes: 1 addition & 6 deletions transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import {
distinct,
isErr,
isNull,
isString,
parse,
RangeHeader,
RepresentationHeader,
Status,
unsafe,
} from "./deps.ts";
Expand Down Expand Up @@ -46,14 +44,11 @@ export async function withContentRange(
response: Response,
context: Context,
): Promise<Response> {
const contentType = response.headers.get(RepresentationHeader.ContentType);

if (
response.status !== Status.OK ||
response.headers.has(RangeHeader.ContentRange) ||
response.headers.get(RangeHeader.AcceptRanges) === Unit.None ||
response.bodyUsed ||
isNull(contentType)
response.bodyUsed
) return response;

const rangeContainer = unsafe(() => parse(context.rangeValue));
Expand Down

0 comments on commit 43900d8

Please sign in to comment.