Skip to documentation

package

@stackline/parse-link-header 1.0.4 — installation and API

Compatibility-first HTTP Link header parser for Node.js and browsers

Install @stackline/parse-link-header

npm install @stackline/[email protected]

Package version: 1.0.4. Metadata verified: 2026-11-12. This is separate from the framework version and demonstration runtime.

Node.js requirement
{"node": ">=12"}
Accepted peer dependencies (declared ranges)
{}

Tested environments are described in the versioned README and linked source checks. A declared peer range is not evidence that every version in it was tested.

Versioned reference

This reference comes from the published @stackline/[email protected] README. Its upstream attribution and license remain with the source. Benchmark and security statements describe the cited tests and advisories, not a guarantee for every application.

Compatibility-first HTTP Link header parser for Node.js and browsers.

Documentation | npm | Issues | Repository

Current package version: 1.0.4


Why this package?

Parse HTTP Link headers into the relation-keyed pagination object used by [email protected]. This independent maintained continuation keeps the CommonJS API while adding native ESM, first-party TypeScript declarations, browser-safe loading, runtime options, and parser hardening.

Compatibility

Item Value
Package @stackline/[email protected]
Node.js runtime >=12
CommonJS / primary entry ./index.js
ES module entry ./index.mjs
Type declarations ./index.d.ts

The maintained package preserves the established contract:

  • callable CommonJS default export;
  • default and named ESM exports;
  • null for empty or silently rejected over-limit input;
  • a plain object keyed by each rel token;
  • query values, URL, relation, and extension parameters on each link;
  • arrays for repeated query keys;
  • expansion of space-separated relations;
  • last-link-wins behavior when a relation is repeated;
  • index and index.js deep imports;
  • the default length bound and historical environment controls.

Intentional hardening discards parser-controlled __proto__, prototype, and constructor keys. Quoted parameters correctly retain semicolons, commas, and escaped quotes. Malformed links remain ignored rather than crashing the whole header.

See COMPATIBILITY_CONTRACT.md and MIGRATION.md for the complete boundary.

Installation

Install

npm install @stackline/parse-link-header

Keep existing source imports unchanged with an npm alias:

Usage

npm install parse-link-header@npm:@stackline/parse-link-header
const parseLinkHeader = require('parse-link-header')
import parseLinkHeader from '@stackline/parse-link-header'

const links = parseLinkHeader(
  '<https://api.example.test/items?page=2>; rel="next", ' +
  '<https://api.example.test/items?page=8>; rel="last"'
)

console.log(links.next.page) // "2"
console.log(links.next.url)  // complete next-page URL

The named ESM export is also available:

import { parseLinkHeader } from '@stackline/parse-link-header'

Features and Integrations

Runtime limits

Parsing is bounded to 2,000 characters by default, preserving the mitigation introduced upstream for CVE-2021-23490. An over-limit value returns null unless throwing is enabled.

parseLinkHeader(header, {
  maxHeaderLength: 8192,
  throwOnMaxHeaderLengthExceeded: true
})

The historical environment variables remain supported:

  • PARSE_LINK_HEADER_MAXLEN
  • PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED

Per-call options take precedence and are suitable for browser applications where process.env is unavailable.

Project documents

Security

Review inputs and the package-specific compatibility limits before processing untrusted data. Report suspected vulnerabilities as described in the security policy.

Local Development

git clone https://github.com/alexandroit/stackline-parse-link-header.git
cd stackline-parse-link-header
npm ci
npm run verify

Release tooling uses Node.js 24.20.0 and npm 11.19.0. The consumer runtime contract remains the one documented above.

Consumer Smoke Test

Run the repository's existing consumer/package check after installing development dependencies:

npm run test:smoke

Release Checklist

Run npm run verify and inspect the package contents before release. Publish a new version through the GitHub Actions publishing workflow, using the SHA-512 digest of the reviewed tarball. Verify the exact published version, tarball integrity, and npm provenance after the run.

License

License and attribution

MIT. The original copyright notice for Thorsten Lorenz is preserved in LICENSE. This project is independent and is not affiliated with or endorsed by the original author.

Credits and original authors

Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.

Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.

Examples and compatibility

The original example runtime is preserved. Its build is identified by source commit fc9b006e6b6091904ad933ff4871bfa93047d3a3. Package version and runtime version must be checked independently.

Open the original example

Examples load only when requested. They have their own runtime and are separate from this reference.

Compatibility Contract — @stackline/parse-link-header

Migration — @stackline/parse-link-header

Third-Party Licenses — @stackline/parse-link-header