Back to Explore

jshttp/content-type

GitHub
4 updates · last 90 daysOpen source

Last release:

This JavaScript/Node.js library helps you create, parse, and format HTTP Content-Type headers. It provides functions to parse a Content-Type string into a media type and parameters, and to format an object back into a header value, which is useful when handling HTTP requests and responses.

Project status

  • The repository appears actively maintained, with recent upstream and project updates as recently as 2026-09-17, and additional updates in 2026-09-10 and 2026-08-20.
  • Apparent update cadence is fairly active, clustering multiple updates within about a month (mid-August through mid-September 2026).

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v3.1.1

    v3.1.1 extends the exported content-type validation helpers to support validating only a substring via start and end offsets. The release notes mention string-offset validation, and the code implements it by changing the function signatures and adjusting the internal index checks accordingly.

    Features
  • v3.1.0

    v3.1.0 focuses on performance improvements for Content-Type parsing and formatting. It also exposes new validation helpers, `isTypeValid` and `isTokenValid`, that are used by `format` to validate types and parameter names.

    Features
  • v3.0.0

    v3.0.0 is published as an ESM-only package. The documented intent is that the API surface (parse/format) remains the same, but the repository changes show broader packaging and runtime requirements changes.

    Breaking
  • v2.1.0

    v2.1.0 extends the parser to optionally stop parsing at the first comma (intended for `Accept` header media ranges). The code change also adds a new `index` field to the public `ContentType` type and introduces a new `start` option to begin parsing from an arbitrary offset.

    Features
  • v2.0.0

    v2.0.0 is a major rewrite of the library (ported to TypeScript) focused on performance (reported as about 3x faster) and on making `parse` lenient. The documented behavior change is that `parse` no longer throws on invalid input, and a new `options.parameters` flag allows skipping parameter parsing.

    Features
  • v1.0.5

    Release 1.0.5 primarily targets performance in the `contentType.parse` implementation by avoiding unnecessary value escaping work when parsing quoted parameters. The code diff also includes substantial development and CI tooling updates (ESLint, test coverage tooling, GitHub Actions vs Travis), though those are not mentioned in the release notes.

  • v1.0.4

    Release v1.0.4 makes a targeted performance change to the Content-Type parsing logic. Specifically, it avoids running the parameter parsing regular expression when the header contains no parameters.

  • v1.0.3

    v1.0.3 is a small refactor release focused on performance, specifically removing argument reassignment. The main production code changes are in parsing/formatting internals of the HTTP Content-Type header.

  • v1.0.2

    Release 1.0.2 is described as a performance improvement by enabling JavaScript strict mode. The runtime code change is minimal, adding 'use strict' to index.js.

  • v1.0.1

    Release v1.0.1 primarily improves the error message thrown when `contentType.parse` is given req/res-like objects missing a `Content-Type` header. The code change specifically adjusts the validation path for object inputs and the related unit test expectations.

  • v1.0.0

    Release 1.0.0 is an initial implementation, derived from media-typer@0.3.0. No additional features, fixes, security updates, or migration guidance are described in the release notes.