Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mikeal
Last active December 22, 2015 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeal/6429576 to your computer and use it in GitHub Desktop.
Save mikeal/6429576 to your computer and use it in GitHub Desktop.
function parselink (headers) {
var links = {}
if (!headers.link) {
return {}
}
headers.link.split(',').forEach(function (s) {
s = s.split(';')
var url = s[0].slice(s[0].indexOf('<')+1, s[0].length - 1)
, name = s[1].slice(' rel="'.length, s[1].length - 1)
;
links[name] = url
})
return links
}
var links = parselinks(resp.headers)
if (links.next) fetchurl(links.next)
else fetchurl(keys.shift())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment