2.0.0 • Published 3 years ago

uri-template v2.0.0

Weekly downloads
18,058
License
MIT
Repository
github
Last release
3 years ago

URI Template

Node.js CI

This is a node.js implementation of the URI template draft standard defined at http://tools.ietf.org/html/rfc6570

Example

var parser = require("uri-template");

var tpl = parser.parse("/{year}/{month}/{day}{?orderBy,direction}");

tpl.expand({ year: 2006, month: 6, day: 6 });
// /2006/6/6

tpl.expand({ year: 2006, month: 6, day: 6, orderBy: "size" });
// /2006/6/6?orderBy=size

tpl.expand({ year: 2006, month: 6, day: 6, orderBy: "time", direction: "asc" });
// /2006/6/6?orderBy=time&direction=asc

var queryTpl = parser.parse("/search{?q,otherParams*}");
queryTpl.expand({
  q: "Bigger office",
  otherParams: { prefer: "Sterling's office", accept: "Crane's office" },
});
// /search?q=Bigger%20office&prefer=Sterling%27s%20office&accept=Crane%27s%20office

For more thorough coverage of the syntax, see the RFC.

2.0.0

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

8 years ago

1.0.0

9 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.3

11 years ago

0.3.4

11 years ago

0.3.2

12 years ago

0.3.1

12 years ago

0.2.1

12 years ago

0.3.0

12 years ago

0.2.0

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.4

12 years ago

0.0.3

13 years ago

0.0.2

13 years ago

0.0.1

13 years ago