Skip to content

Commit

Permalink
docs: document typeis.match(expected, actual)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jan 26, 2022
1 parent 044e1a9 commit cdcfe23
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ typeis.is(mediaType, ['application/json']) // => 'application/json'
typeis.is(mediaType, ['html']) // => false
```

### typeis.match(expected, actual)

Match the type string `expected` with `actual`, taking in to account wildcards.
A wildcard can only be in the type of the subtype part of a media type and only
in the `expected` value (as `actual` should be the real media type to match). A
suffix can still be included even with a wildcard subtype. If an input is
malformed, `false` will be returned.

```js
typeis.match('text/html', 'text/html') // => true
typeis.match('*/html', 'text/html') // => true
typeis.match('text/*', 'text/html') // => true
typeis.match('*/*', 'text/html') // => true
typeis.match('*/*+json', 'application/x-custom+json') // => true
```

### typeis.normalize(type)

Normalize a `type` string. This works by performing the following:
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function normalize (type) {
* @param {String} expected
* @param {String} actual
* @return {Boolean}
* @private
* @public
*/

function mimeMatch (expected, actual) {
Expand Down

0 comments on commit cdcfe23

Please sign in to comment.