Module

x/oak/deps.ts>matches

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Extremely Popular
Go to Latest
function matches
import { matches } from "https://dotland.deno.dev/x/oak@v13.2.5/deps.ts";

Determines if the provided media type matches one of the supplied media types. If there is a match, the matched media type is returned, otherwise undefined is returned.

Each type in the media types array can be one of the following:

  • A file extension name such as json. This name will be returned if matched.
  • A media type such as application/json.
  • A media type with a wildcard such as *​/* or *​/json or application/*. The full media type will be returned if matched.
  • A suffix such as +json. This can be combined with a wildcard such as *​/vnd+json or application/*+json. The full mime type will be returned if matched.
  • Special cases of urlencoded and multipart which get normalized to application/x-www-form-urlencoded and multipart/* respectively.

Parameters

value: string
mediaTypes: string[]

Returns

string | undefined