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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const obj = contentType.parse("image/svg+xml; charset=utf-8");

Parse a `Content-Type` header. This will return an object with the following properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):

- `type`: The media type. Example: `'image/svg+xml'`.
- `type`: The media type (always lower case). Example: `'image/svg+xml'`.
- `parameters`: An object of the parameters in the media type (parameter name is always lower case). Example: `{charset: 'utf-8'}`.
- `index`: The index where parsing stopped. Example: `33`.

Expand Down Expand Up @@ -56,6 +56,13 @@ Format an object into a `Content-Type` header. This will return a string of the

Throws a `TypeError` if the object contains an invalid type or parameter names.

### Validation

This package exposes the validation functions used by `format`:

- `isTypeValid` Validates the MIME type against RFC 9110.
- `isTokenValid` Validates a token against RFC 9110 (used for the parameter name).

## License

[MIT](LICENSE)
Expand Down
Loading
Loading