npm install @ferrow/content-negotiationHTTP Accept header negotiation with q-values, specificity ordering, and media-type matching per RFC 9110.
import { parseAccept, negotiate } from "content-negotiation";
const accept = "text/html, application/json;q=0.9";
const available = ["text/html", "application/json", "text/plain"];
const best = negotiate(accept, available); // → "text/html"Parse Accept header; returns sorted by specificity then q-value.
Specificity: exact type/subtype > type/* > /
Parse Accept-Language header; sorted by q-value.
Find best match from available options, or null if none match.
- Parameters parsed but not matched during negotiation
- No Accept-Encoding or Accept-Charset (extend with parseAccept)
- Language subtags not matched (exact match only)
Part of the ferrow-toolkit collection · Sponsored by Ferrow