1.1.0 • Published 5 months ago

rfc6570-uri-template v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

rfc6570-uri-template

RFC 6570 URI template parser

Getting started

import { parse } from 'rfc6570-uri-template';

const template = parse('http://www.example.com/users/{id}');
const url = template.expand({ id: 1 }); // http://www.example.com/users/1

Examples

url = parse('{controller}/{action}').expand({ controller: 'books', action: 'read' });\ books/read

url = parse('foo{?query,number}').expand({ query: 'mycelium', number: 100 });\ foo?query=mycelium&number=100

url = parse('X{#hello}').expand({ hello: 'Hello World!' });\ X#Hello%20World!

url = parse('{+path:6}/here').expand({ path: '/foo/bar' });\ /foo/b/here

url = parse('{list}').expand({ list: ['red', 'green', 'blue'] });\ red,green,blue

url = parse('{keys}').expand({ keys: { semi: ';', dot: '.', comma: ',' } });\ semi,%3B,dot,.,comma,%2C

url = parse('{keys*}').expand({ keys: { semi: ';', dot: '.', comma: ',' } });\ semi=%3B,dot=.,comma=%2C

See more examples in the RFC 6570 specification.

GitHub · NPM package

1.1.0

5 months ago

1.0.0

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.0.1-security

1 year ago