Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/.stale.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .github/tests_checker.yml

This file was deleted.

14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
# fast-content-type-parse

<div align="center">

[![NPM version](https://img.shields.io/npm/v/fast-content-type-parse.svg?style=flat)](https://www.npmjs.com/package/fast-content-type-parse)
[![NPM downloads](https://img.shields.io/npm/dm/fast-content-type-parse.svg?style=flat)](https://www.npmjs.com/package/fast-content-type-parse)
[![CI](https://github.com/fastify/fast-content-type-parse/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fast-content-type-parse/actions/workflows/ci.yml)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
[![Security Responsible Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/fastify/.github/blob/main/SECURITY.md)

</div>

Parse HTTP Content-Type header according to RFC 7231.

## Installation

```sh
$ npm install fast-content-type-parse
npm install fast-content-type-parse
```

## Usage
Expand All @@ -35,10 +31,10 @@ Parse a `Content-Type` header. Throws a `TypeError` if the string is invalid.
It will return an object with the following properties (examples are shown for
the string `'application/json; charset=utf-8'`):

- `type`: The media type (the type and subtype, always lowercase).
- `type`: The media type (the type and subtype, always lowercase).
Example: `'application/json'`

- `parameters`: An object of the parameters in the media type (name of parameter
- `parameters`: An object of the parameters in the media type (name of parameter
always lowercase). Example: `{charset: 'utf-8'}`

### fastContentTypeParse.safeParse(string)
Expand All @@ -52,10 +48,10 @@ Parse a `Content-Type` header. It will not throw an Error if the header is inval
This will return an object with the following
properties (examples are shown for the string `'application/json; charset=utf-8'`):

- `type`: The media type (the type and subtype, always lowercase).
- `type`: The media type (the type and subtype, always lowercase).
Example: `'application/json'`

- `parameters`: An object of the parameters in the media type (name of parameter
- `parameters`: An object of the parameters in the media type (name of parameter
always lowercase). Example: `{charset: 'utf-8'}`

In case the header is invalid, it will return an object
Expand Down