mirror of
https://github.com/denoland/std.git
synced 2024-11-21 12:40:03 +00:00
fix(http): less restrictive arguments for accepts*()
functions (#5850)
* fix(http): less restrictive types * tweaks --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
parent
a7e072881c
commit
b8df2b3494
@ -41,7 +41,7 @@ import { preferredMediaTypes } from "./_negotiation/media_type.ts";
|
||||
* @param request The request to get the acceptable media types for.
|
||||
* @returns An array of acceptable media types.
|
||||
*/
|
||||
export function accepts(request: Request): string[];
|
||||
export function accepts(request: Pick<Request, "headers">): string[];
|
||||
/**
|
||||
* For a given set of media types, return the best match accepted in the
|
||||
* request. If no media type matches, then the function returns `undefined`.
|
||||
@ -66,11 +66,11 @@ export function accepts(request: Request): string[];
|
||||
* @returns The best matching media type, if any match.
|
||||
*/
|
||||
export function accepts(
|
||||
request: Request,
|
||||
request: Pick<Request, "headers">,
|
||||
...types: string[]
|
||||
): string | undefined;
|
||||
export function accepts(
|
||||
request: Request,
|
||||
request: Pick<Request, "headers">,
|
||||
...types: string[]
|
||||
): string | string[] | undefined {
|
||||
const accept = request.headers.get("accept");
|
||||
@ -101,7 +101,7 @@ export function accepts(
|
||||
* @param request The request to get the acceptable content encodings for.
|
||||
* @returns An array of content encodings this request accepts.
|
||||
*/
|
||||
export function acceptsEncodings(request: Request): string[];
|
||||
export function acceptsEncodings(request: Pick<Request, "headers">): string[];
|
||||
/**
|
||||
* For a given set of content encodings, return the best match accepted in the
|
||||
* request. If no content encodings match, then the function returns
|
||||
@ -128,11 +128,11 @@ export function acceptsEncodings(request: Request): string[];
|
||||
* @returns The best matching encoding, if any match.
|
||||
*/
|
||||
export function acceptsEncodings(
|
||||
request: Request,
|
||||
request: Pick<Request, "headers">,
|
||||
...encodings: string[]
|
||||
): string | undefined;
|
||||
export function acceptsEncodings(
|
||||
request: Request,
|
||||
request: Pick<Request, "headers">,
|
||||
...encodings: string[]
|
||||
): string | string[] | undefined {
|
||||
const acceptEncoding = request.headers.get("accept-encoding");
|
||||
@ -167,7 +167,7 @@ export function acceptsEncodings(
|
||||
* @param request The request to get the acceptable languages for.
|
||||
* @returns An array of languages this request accepts.
|
||||
*/
|
||||
export function acceptsLanguages(request: Request): string[];
|
||||
export function acceptsLanguages(request: Pick<Request, "headers">): string[];
|
||||
/**
|
||||
* For a given set of languages, return the best match accepted in the request.
|
||||
* If no languages match, then the function returns `undefined`.
|
||||
@ -191,11 +191,11 @@ export function acceptsLanguages(request: Request): string[];
|
||||
* @returns The best matching language, if any match.
|
||||
*/
|
||||
export function acceptsLanguages(
|
||||
request: Request,
|
||||
request: Pick<Request, "headers">,
|
||||
...langs: string[]
|
||||
): string | undefined;
|
||||
export function acceptsLanguages(
|
||||
request: Request,
|
||||
request: Pick<Request, "headers">,
|
||||
...langs: string[]
|
||||
): string | string[] | undefined {
|
||||
const acceptLanguage = request.headers.get("accept-language");
|
||||
|
Loading…
Reference in New Issue
Block a user