node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »


parse-link-header build status

testling badge

Parses a link header and returns paging information for each contained link.

var parse = require('parse-link-header');
var linkHeader =
  '<>; rel="next", ' +
  '<>; rel="prev"; pet="cat", ' +
  '<>; rel="last"'
var parsed = parse(linkHeader);
{ next:
   { page: '3',
     per_page: '100',
     rel: 'next',
     url: '' },
   { page: '1',
     per_page: '100',
     rel: 'prev',
     pet: 'cat',
     url: '' },
   { page: '5',
     per_page: '100',
     rel: 'last',
     url: '' } }


npm install parse-link-header


parseLinkHeader(linkHeader : String) : Object

Parses the given link header containing web links and returns an object keyed by the rel property that contains information about each link.

Formatting a link header

The purpose of this module it´s to parse the link header information. To format an object generated by this module back to the link header string use the format-link-header module.