-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
20 lines (16 loc) · 857 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@author Rowan Crawford (wombleton@gmail.com)
@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