Socket
Socket
Sign inDemoInstall

uri-template

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uri-template

Parse and expand URI templates as defined by http://tools.ietf.org/html/rfc6570


Version published
Weekly downloads
91K
increased by5.6%
Maintainers
2
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 24 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc