@contentgrid/uri-template
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

@contentgrid/uri-template

RFC 6570 compliant URI template parser and expander.

Usage

import UriTemplate from '@contentgrid/uri-template'

const template = new UriTemplate("http://example.com/{resource}/search{?color,height}");


// Expand using named keys
template.expand({ resource: "cars" }) // -> "http://example.com/cars/search"

// Expand using positional keys
template.expand(["cars", "blue"]) // -> "http://example.com/cars/search?color=blue"

// Parsing URLs
template.match("http://example.com/cars/search") // -> { resource: "cars" }
template.match("http://example.org/something-else") // -> null

Package Sidebar

Install

npm i @contentgrid/uri-template

Weekly Downloads

90

Version

0.3.0

License

MIT

Unpacked Size

9.98 kB

Total Files

8

Last publish

Collaborators

  • xenit-jenkins