Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Parses a link header and returns paging information for each contained link.
JavaScript
Branch: master

0.4.1

latest commit ef445e525e
@thlorenz authored

README.md

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 = 
  '<https://api.github.com/user/9287/repos?page=3&per_page=100>; rel="next", ' + 
  '<https://api.github.com/user/9287/repos?page=1&per_page=100>; rel="prev"; pet="cat", ' + 
  '<https://api.github.com/user/9287/repos?page=5&per_page=100>; rel="last"'

var parsed = parse(linkHeader);
console.log(parsed);
{ next:
   { page: '3',
     per_page: '100',
     rel: 'next',
     url: 'https://api.github.com/user/9287/repos?page=3&per_page=100' },
  prev:
   { page: '1',
     per_page: '100',
     rel: 'prev',
     pet: 'cat',
     url: 'https://api.github.com/user/9287/repos?page=1&per_page=100' },
  last:
   { page: '5',
     per_page: '100',
     rel: 'last',
     url: 'https://api.github.com/user/9287/repos?page=5&per_page=100' } }

Installation

npm install parse-link-header

API

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.

Something went wrong with that request. Please try again.