An HTTP content negotiator for Node.js that parses client headers like Accept, Accept-Language, Accept-Charset, and Accept-Encoding to rank and select the most preferred media types, languages, charsets, and encodings. Useful for choosing what content format to respond with based on a request’s preference headers.
Project status
- jshttp/negotiator appears actively maintained, with an upstream push and tagged update on 2026-08-20 (about a week before today, 2026-08-27).
- The update cadence is irregular, with a long gap between substantive updates (latest prior version shown is 2024-10-19) followed by a recent update on 2026-08-20.
AI summary generated
Recent updates
v1.1.0
v1.1.0 refactors Accept header parsing to use the `content-type` package, aiming for faster header parsing performance. The release notes mention parsing speed improvements and a Node engines fix, but the code diff also introduces changes to public method signatures and effective runtime support.
v0.6.4
v0.6.4 release notes state two user-visible changes, adding a preferred encodings option and replacing deprecated String.prototype.substr usage. However, the provided code diff shows only a version bump in package.json and no actual source changes.
Featuresv1.0.0
This release is version 1.0.0 and primarily introduces support for developer-preferred encoding ordering, controlled via a new `preferred` array option. It also drops support for Node versions below 18 and modernizes CI/test Node targets.
BreakingFeatures0.6.3
Version 0.6.3 reverts a previous change related to lazy-loading internal charset, encoding, language, and media type modules. The primary code change is in `index.js`, where negotiator now requires these modules at startup instead of loading them on demand.
Breaking0.6.2
Release 0.6.2 updates the library to correctly handle Accept parameters for charsets, encodings, and languages so results are sorted as expected even when extra parameters are present. The code changes primarily adjust how parsing loops handle parameter lists, and the release also updates development tooling and test infrastructure.
0.6.1
Release 0.6.1 is presented as a pure performance update, claiming faster parsing for the Accept family of HTTP headers: Accept, Accept-Charset, Accept-Encoding, and Accept-Language. The code changes are small but they do modify the underlying token matching regular expressions used by the header parsers.
0.6.0
Version 0.6.0 focuses on correcting Accept header parameter parsing edge cases (especially around quoted values) and improving runtime performance. It also introduces lazy-loading and stricter code (use strict) to reduce startup work and allocation overhead.
0.5.3
Version 0.5.3 updates media type parameter matching so parameter names are treated case-insensitively. The change is implemented in media type parsing and is covered by new unit tests.
0.5.2
Release 0.5.2 focuses on fixing HTTP Accept header parsing for media types when parameter values are quoted and when quoted commas appear inside those values. The runtime change is in media type parsing, improving how the library splits and interprets media type parameters.
0.5.1
This release (0.5.1) focuses on fixing how negotiator results are sorted when the client sends long Accept headers. The code changes adjust the internal tie-breaking logic so the output ordering is stable. Documentation and tests were updated to reflect and validate the behavior.
0.5.0
Release 0.5.0 focuses on fixing HTTP content negotiation edge cases, specifically ordering issues for large Accept-Language/MediaType/etc lists and a bug where identity encoding handling could fail when q=0 was present. It also removes the dynamic construction of the Negotiator prototype, replacing it with explicit method definitions.