File tree Expand file tree Collapse file tree 2 files changed +53
-3
lines changed
Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Original file line number Diff line number Diff line change 1- # parse-link-header
2- [ ![ build status] ( https://secure.travis-ci.org/thlorenz/parse-link-header.png )] ( http://travis-ci.org/thlorenz/parse-link-header )
1+ # parse-link-header [ ![ build status] ( https://secure.travis-ci.org/thlorenz/parse-link-header.png )] ( http://travis-ci.org/thlorenz/parse-link-header )
32
43[ ![ testling badge] ( https://ci.testling.com/thlorenz/parse-link-header.png )] ( https://ci.testling.com/thlorenz/parse-link-header )
54
6- Parses a link header and returns paging information for each contained link.
5+ Parses a link header and returns paging information for each contained link.
6+
7+ ``` js
8+ var parse = require (' parse-link-header' );
9+
10+ var linkHeader =
11+ ' <https://api.github.com/user/9287/repos?page=3&per_page=100>; rel="next", ' +
12+ ' <https://api.github.com/user/9287/repos?page=1&per_page=100>; rel="prev"; pet="cat", ' +
13+ ' <https://api.github.com/user/9287/repos?page=5&per_page=100>; rel="last"'
14+
15+ var parsed = parse (linkHeader);
16+ console .log (parsed);
17+ ```
18+
19+ ``` js
20+ { next:
21+ { page: ' 3' ,
22+ per_page: ' 100' ,
23+ rel: ' next' ,
24+ url: ' https://api.github.com/user/9287/repos?page=3&per_page=100' },
25+ prev:
26+ { page: ' 1' ,
27+ per_page: ' 100' ,
28+ rel: ' prev' ,
29+ pet: ' cat' ,
30+ url: ' https://api.github.com/user/9287/repos?page=1&per_page=100' },
31+ last:
32+ { page: ' 5' ,
33+ per_page: ' 100' ,
34+ rel: ' last' ,
35+ url: ' https://api.github.com/user/9287/repos?page=5&per_page=100' } }
36+ ```
37+
38+ ## Installation
39+
40+ npm install parse-link-header
41+
42+ ## API
43+
44+ *** parseLinkHeader(linkHeader : String) : Object***
45+
46+ Parses the given link header containing [ web links] ( http://tools.ietf.org/html/rfc5988 ) and returns an object keyed by
47+ the ` rel ` property that contains information about each link.
Original file line number Diff line number Diff line change 1+ var parse = require ( '..' ) ;
2+
3+ var linkHeader =
4+ '<https://api.github.com/user/9287/repos?page=3&per_page=100>; rel="next", ' +
5+ '<https://api.github.com/user/9287/repos?page=1&per_page=100>; rel="prev"; pet="cat", ' +
6+ '<https://api.github.com/user/9287/repos?page=5&per_page=100>; rel="last"'
7+
8+ var parsed = parse ( linkHeader ) ;
9+ console . log ( parsed ) ;
You can’t perform that action at this time.
0 commit comments