Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

parse-link-header

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-link-header - npm Package Compare versions

Comparing version 0.4.1 to 1.0.0

7

index.js

@@ -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()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc