View on GitHub

uri-template

Javascript RFC 6570 URI template

Download this project as a .zip file Download this project as a tar.gz file

uri-template

Javascript RFC 6570 URI templating.

Installation

npm install @btilford/uri-template

Usage


const { UriTemplate } = require('@btilford/uri-template');

const template = UriTemplate.parse('https://github.com/btilford/js-uri-template/tree/{/branch}');
const url = template.expand({branch:'master'}).format();
// https://github.com/btilford/js-uri-template/tree/master

See usage for more examples.

Features

Variable Types

Other

Builder

There is also a template builder available to build template strings.


const { UriTemplateBuilder } = require('@btilford/uri-template');

const templateString = UriTemplateBuilder.from('https://github.com/btilford/js-uri-template/blob')
    .path('branch', 'file')
    .format();
// https://github.com/btilford/js-uri-template/blob{/branch,file}