parse-link-header
Parses a link header and returns paging information for each contained link.
Last updated 3 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install parse-link-header 
SYNC missed versions from official npm registry.

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.

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.

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

9 Versions

  • 2.0.0                                ...           3 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           8 years ago
  • 0.4.1                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.1                                ...           9 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |