parse-link-header
Advanced tools
Comparing version 0.4.1 to 1.0.0
@@ -30,7 +30,10 @@ 'use strict'; | ||
try { | ||
var parts = link.split(';') | ||
, linkUrl = parts.shift().replace(/[<>]/g, '') | ||
var m = link.match(/<?([^>]*)>(.*)/) | ||
, linkUrl = m[1] | ||
, parts = m[2].split(';') | ||
, parsedUrl = url.parse(linkUrl) | ||
, qry = qs.parse(parsedUrl.query); | ||
parts.shift(); | ||
var info = parts | ||
@@ -37,0 +40,0 @@ .reduce(createObjects, {}); |
{ | ||
"name": "parse-link-header", | ||
"version": "0.4.1", | ||
"version": "1.0.0", | ||
"description": "Parses a link header and returns paging information for each contained link.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,5 +10,5 @@ # parse-link-header [![build status](https://secure.travis-ci.org/thlorenz/parse-link-header.png)](http://travis-ci.org/thlorenz/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", ' + | ||
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"' | ||
@@ -49,1 +49,5 @@ | ||
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](https://github.com/jonathansamines/format-link-header) module. |
@@ -140,3 +140,3 @@ 'use strict'; | ||
var linkHeader = | ||
'<https://imaginary.url.notreal/?name=What,+me+worry; rel="next";' | ||
'<https://imaginary.url.notreal/?name=What,+me+worry>; rel="next";' | ||
@@ -158,3 +158,3 @@ var res = parse(linkHeader) | ||
var linkHeader = | ||
'<https://imaginary.url.notreal/?name=What,+me+worry; rel="next page";' | ||
'<https://imaginary.url.notreal/?name=What,+me+worry>; rel="next page";' | ||
@@ -175,1 +175,17 @@ var res = parse(linkHeader) | ||
}) | ||
test('parsing a proper link header with matrix parameters', function (t) { | ||
var linkHeader = | ||
'<https://imaginary.url.notreal/segment;foo=bar;baz/item?name=What,+me+worry>; rel="next";' | ||
var res = parse(linkHeader) | ||
t.deepEqual( | ||
parse(linkHeader) | ||
, { next: { rel: 'next', | ||
name: 'What, me worry', | ||
url: 'https://imaginary.url.notreal/segment;foo=bar;baz/item?name=What,+me+worry' }} | ||
, 'correctly parses url with matrix parameters' | ||
) | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11322
214
0
52