uri-template-w-unescaped
Parse and expand URI templates as defined by http://tools.ietf.org/html/draft-gregorio-uritemplate-08, with the additional, non-RFC {%unescaped} expression
Last updated 8 years ago by jzetlen .
Repository · Original npm · Tarball · package.json
$ cnpm install uri-template-w-unescaped 
SYNC missed versions from official npm registry.

URI Template

Build Status

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

Example


parser = require('uri-template')

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

tpl = parser.parse('/search{?q,*otherParams}')
tpl.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 test.js or the RFC.

Current Tags

  • 0.0.1                                ...           latest (8 years ago)

1 Versions

  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |