http-header-list
Version:
Parser and logic functions for HTTP header lists
76 lines (53 loc) • 3.11 kB
Markdown
Parser and logic functions for HTTP header lists
[](https://gitlab.com/bytesnz/http-header-list/-/commits/main)
[](https://npmjs.com/package/http-header-list)
[](https://gitlab.com/bytesnz/http-header-list/-/blob/main/LICENSE)
[](https://gitlab.com/bytesnz/http-header-list/-/blob/main/.tickings)
[](https://gitlab.com/bytesnz/http-header-list/-/blob/main/CODE_OF_CONDUCT.md)
[](https://liberapay.com/MeldCE)
A dependency-free module to parse HTTP headers like `Accept` logic functions
to run common checks like finding the first matching value.
```js
/* eslint-disable no-console */
import { HeaderList } from 'http-header-list';
const acceptList = new HeaderList(
'text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8'
);
const type = acceptList.firstMatch(['application/xml', 'application/xhtml+xml']);
console.log(type);
/* Output will be:
* { value: 'application/xhtml+xml', weight: 1, parameters: {} }
*/
```
Feel free to post errors or feature requests to the project
[](https://gitlab.com/bytesnz/http-header-list/issues) or
[](mailto:contact-project+bytesnz-http-header-list-38124105-issue-@incoming.gitlab.com) them to us.
**Please submit security concerns as a
[](https://gitlab.com/bytesnz/http-header-list/issues?issue[confidential]=true)**
The source is hosted on [Gitlab](https://gitlab.com/bytesnz/http-header-list) and uses
[][], [prettier][], [lint-staged][] and [husky][] to keep things pretty.
As such, when you first [clone][git-clone] the repository, as well as
installing the npm dependencies, you will also need to install [husky][].
```bash
npm install
npx husky install
```
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
Initial version!
[]: https://gitlab.com/bytesnz/http-header-list/-/compare/v1.0.0...v1.1.0
[]: https://gitlab.com/bytesnz/http-header-list/-/tree/v1.0.0
[]: https://typicode.github.io/husky
[]: https://eslint.org/
[]: https://www.git-scm.com/docs/git-clone
[]: https://prettier.io/
[]: https://github.com/okonet/lint-staged#readme
[]: https://docs.gitlab.com/ee/ci/