Parse and format Link header according to RFC 5988.
Install
$ npm install li
Also works with bower, component.js, browserify, amd, etc.
Usage
Parse a Link header:
var li = require('li');
var someLinksHeader = '</api/users?page=0&per_page=2>; rel="first", ' +
'</api/users?page=1&per_page=2>; rel="next", ' +
'</api/users?page=3&per_page=2>; rel="last"';
console.log(li.parse(someLinksHeader));
Generate a Link header as follow with stringify:
var linksObject = {
first : '/api/users?page=0&per_page=2',
next : '/api/users?page=1&per_page=2',
last : '/api/users?page=3&per_page=2',
};
console.log(li.stringify(linksObject);
Testing
$ npm test
License
MIT 2014 - JOSE F. ROMANIELLO