Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ql.io-uri-template

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ql.io-uri-template

A small URI template processor for ql.io.

  • 0.4.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

This module provides a small URI template parser. ql.io uses URI templates for specifying URIs of APIs. See docs for more examples.

Syntax Overview

Here is overview of the syntax.

  1. Each template can have an arbitrary number of tokens enclosed in braces ({ and }).

    http://myserver/somepath?p1={v1}&p2={v2}

  2. You can generate URIs from URI templates by calling the format() function with an object containing values, and optionally, default values.

  3. All tokens are optional and single valued by default.

  4. You can mark that a token is required by prefixing the name of the token with ^. When the value for a required token is missing, formatting will fail.

    http://myserver/somepath?p1={^v1}&p2={v2}

  5. You can also mark that a token is multi-valued by prefixing the name of the token with a |.

    http://myserver/somepath?p2={|v2}

If the value of v2 is ['v2_1','v2_2'], calling the format() would result in

http://myserver/somepath?p2=v2_1,v2_2

Some APIs may not take more than a given number of values. In such cases, you can specify a maximum integer before |.

http://myserver/somepath?p1={^v1}&p2={5|v2}

If you supply more than 5 values, the format() function will return Math.ceil(n/5) URIs.

FAQs

Package last updated on 28 Mar 2012

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