# uritemplate

> An UriTemplate implementation of rfc 6570

Latest version **0.3.4** (published 2013-07-13) · 0 weekly downloads

## Install

```sh
npm install uritemplate
pnpm add uritemplate
yarn add uritemplate
bun add uritemplate
```

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2013-07-13 |
| First published | 2012-06-10 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/uritemplate) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 97 |
| Author | Franz X Antesberger |
| Maintainers | fxa |
| Keywords | util, uri, template, rfc6570 |

## Links

- npm: https://www.npmjs.com/package/uritemplate
- Repository: https://github.com/fxa/uritemplate-js
- Homepage: https://www.github.com/fxa/uritemplate-js
- Issues: https://github.com/fxa/uritemplate-js/issues
- npm.io page: https://npm.io/package/uritemplate

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.3.4 (latest) — 2013-07-13
- 0.3.3 — 2013-05-26
- 0.3.2 — 2013-05-18
- 0.3.1 — 2013-03-17
- 0.2.4 — 2013-01-27
- 0.2.3 — 2013-01-20
- 0.2.2 — 2013-01-19
- 0.2.1 — 2013-01-15
- 0.2.0 — 2013-01-15
- 0.1.3 — 2012-06-30
- 0.1.2 — 2012-06-15
- 0.1.1 — 2012-06-10

## README

URI Template JS
===============

This is a javascript implementation of [RFC6570](http://tools.ietf.org/html/rfc6570) - URI Template,
and can expand templates up to and including Level 4 in that specification.

It exposes a constructor function UriTemplate with the two methods:

* (static) parse(uriTemplateText) returning an instance of UriTemplate
* expand(variables) returning an string

Be aware, that a parsed UriTemplate is frozen, so it is stateless. You can reuse instances of UriTemplates.

Requirements
------------

You can use uritemplate.js in any even not so modern browser (Tested even with IE8 in IE7-Mode), see file demo.html.
But you can also use it with node:

**npm install uritemplate**

and then in a node application:

    var
        UriTemplate = require('uritemplate'),
        template;
    template = UriTemplate.parse('{?query*})';
    template.expand({query: {first: 1, second: 2}});
    --> "?first=1&second=2"

or within a html document (see also demo.html):

    <script type="text/javascript" src="bin/uritemplate.js"></script>
    <script type="text/javascript">
        var template = UriTemplate.parse('{?query*}');
        alert(template.expand({query: {first: 1, second: 2}}));
    </script>


If you want to clone the git project, be aware of the submodule uritemplate-test.
So you have to to:

    git clone --recursive https://github.com/fxa/uritemplate-js.git

    
Build
-----
    npm install
    npm test

Tests
-----

The integration tests are taken from https://github.com/uri-templates/uritemplate-test as a submodule.
The tests are integrated in the Jakefile.

License
-------
Copyright 2013 Franz Antesberger

MIT License, see http://mit-license.org/

Release Notes
-------------
* 0.3.4 minor package.json changes to support npm install and npm test 
* 0.3.3 fixed https://github.com/fxa/uritemplate-js/issues/12 Pct-Encoding-Error with chars < 0x100 (missing 0-padding). Thanks to https://github.com/pfraze!
* 0.3.2 fixed https://github.com/fxa/uritemplate-js/issues/11 Problems with older IE versions. Thanks to anozaki!
* 0.3.1 fixed https://github.com/fxa/uritemplate-js/issues/10 thank you, Paul-Martin!
* 0.3.0 introduced UriTemplateError as exception, so the interface changed from string to UriTemplateError (as the rfc suggested)
* 0.2.4 fixed double encoding according [RubenVerborgh] and some Prefix modifiers bugs
* 0.2.3 fixed bug with empty objects ('{?empty}' with '{empty:{}}' shall expand to '?empty=')
* 0.2.2 fixed pct encoding bug with multibyte utf8 chars
* 0.2.1 fixed a bug in package.json
* 0.2.0 heavy project refactoring, splitting source files, introducing jshint (preparation of next steps)

Next Steps
----------
* Implementing more unit tests (now only a view tests are implemented)
* A new method extract(uri), which tries to extract the variables from a given uri.
  This is harder, than you might think

---
_Source: https://npm.io/package/uritemplate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
