Created
September 12, 2014 03:52
-
-
Save ophentis/572f7e8785573c5aa36e to your computer and use it in GitHub Desktop.
http link header parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseLink(link) { | |
var links = {} | |
link.split(/\s*,\s*(?=<)/).forEach(function(l, i) { | |
var parts = l.match(/(?:<(\S+)>; rel="(\S*)",?)/) | |
if(parts.length == 3) { | |
links[parts[2]] = parts[1] | |
} | |
}) | |
return links; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment