npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stackline/parse-link-header

v1.0.0

Published

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

Readme

@stackline/parse-link-header

CI npm license

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.

Install

npm install @stackline/parse-link-header

Keep existing source imports unchanged with an npm alias:

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

Usage

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'

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.

Compatibility

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.

Support

  • Node.js 12 through 24 are tested.
  • CommonJS, native ESM, and browser bundles are tested.
  • TypeScript 3.9 and the current compiler are tested.
  • The package has zero runtime dependencies.

Project documents

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.