Skip to content

wombleton/link-headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

@author Rowan Crawford ([email protected])
@version 0.2
@requires jQuery, $.uritemplate
@link http://github.com/wombleton/link-headers

JavaScript parsing of linkheaders as per http://tools.ietf.org/html/draft-nottingham-http-link-header-10

Usage: 
var linkHeader = '</collection/{itemId}>; rel="foo foz bar"; type="application/json", </fozzes/{fozId}>; rel="foz baz"; type="application/json"';
var links = $.linkheaders(linkHeader);
links.find('foo bar').href().expand({ itemId: 'xxx' }) => /collection/xxx
links.find(['foz']).href().expand({ itemId: 'xxx' }) => /collection/xxx
links.find('baz').rel() => 'foz baz'
links.find('foz').attr('type') => 'application/json
links.findAll('foz') => Array with two links
links.each(fn) => calls fn(i, link) on each link.
links.each('foo', fn) => calls fn(i, link) on each link that has rel 'foo'.

MIT License

About

JavaScript parsing of link headers as described by RFC 5988

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published