http-link-header is a JavaScript library designed for parsing and formatting HTTP Link headers as defined by RFC 8288 (which supersedes RFC 5988). The current stable version is 1.1.3, last published in 2018, indicating a low or absent release cadence. A key characteristic is its explicit deviation from RFC 8288 regarding relative URI-References: the library does *not* automatically resolve them, leaving this responsibility to the user. This design choice is critical for developers to be aware of, as it means the parsed URIs might not be absolute without further processing. The library provides methods for parsing single or multiple headers, checking for specific references, retrieving references by attribute, and setting/uniquely setting new references, along with stringifying Link objects back into HTTP header format.
npm install http-link-headerVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a complex HTTP Link header string (including extended attributes), accessing individual references, filtering by relation type, adding new unique references, and stringifying the Link object back to a header format.
Implement custom URI resolution logic using a base URI after parsing the Link header. For example, `new URL(link.refs[0].uri, baseUrl).toString()`.
Use `const LinkHeader = require('http-link-header');` for CommonJS environments. In ES module contexts, consider using a bundler (e.g., Webpack, Rollup) or evaluate alternatives that offer native ESM support.Evaluate if this library meets your long-term needs. For new projects or critical applications, consider alternatives like `@hugoalh/http-header-link` (which supports ESM/TypeScript) or be prepared to fork and maintain the package yourself.
Change your import statement to `const LinkHeader = require('http-link-header');` or configure your TypeScript/bundler setup to handle CommonJS modules.Ensure you are using `const LinkHeader = require('http-link-header');` to get the correct CommonJS module export that exposes the `parse` static method.After parsing, manually resolve relative URIs against a known base URL (e.g., the URL of the document that returned the Link header) using `new URL(relativeUri, baseUrl).href`.
No dependency data recorded yet.