# uri-template-lite

> URI Template [RFC 6570] expansion and extraction

Latest version **23.4.0** (published 2023-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install uri-template-lite
pnpm add uri-template-lite
yarn add uri-template-lite
bun add uri-template-lite
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 23.4.0 |
| Published | 2023-04-25 |
| First published | 2014-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/uri-template-lite) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Lauri Rooden |
| Maintainers | lauriro |
| Keywords | uri, url, template, uri-template, rfc6570, litejs |

## Links

- npm: https://www.npmjs.com/package/uri-template-lite
- Repository: https://github.com/litejs/uri-template-lite
- Homepage: https://github.com/litejs/uri-template-lite#readme
- Issues: https://github.com/litejs/uri-template-lite/issues
- npm.io page: https://npm.io/package/uri-template-lite

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 23.4.0 (latest) — 2023-04-25
- 22.9.0 — 2022-09-09
- 22.1.0 — 2022-01-18
- 20.5.0 — 2020-05-26
- 19.12.0 — 2019-12-16
- 19.11.0 — 2019-11-28
- 19.4.0 — 2019-04-11
- 0.1.11 — 2015-02-09
- 0.1.10 — 2014-12-08
- 0.1.8 — 2014-05-21
- 0.1.7 — 2014-05-21
- 0.1.6 — 2014-05-20
- 0.1.4 — 2014-05-03
- 0.1.3 — 2014-05-03
- 0.1.2 — 2014-01-20
- … 7 more at https://npm.io/package/uri-template-lite/versions

## README

[1]: https://badgen.net/coveralls/c/github/litejs/uri-template-lite
[2]: https://coveralls.io/r/litejs/uri-template-lite
[3]: https://badgen.net/packagephobia/install/uri-template-lite
[4]: https://packagephobia.now.sh/result?p=uri-template-lite
[5]: https://badgen.net/badge/icon/Buy%20Me%20A%20Tea/orange?icon=kofi&label
[6]: https://www.buymeacoffee.com/lauriro

[RFC 6570]: http://tools.ietf.org/html/rfc6570


URI Template Lite &ndash; [![Coverage][1]][2] [![size][3]][4] [![Buy Me A Tea][5]][6]
=================

URI Template [RFC 6570][] expansion and extraction.


Usage
-----

`npm install uri-template-lite`

```javascript
var UriTemplate = require("uri-template-lite")

// Call `expand` directly
var data = {"domain":"example.com", "user":"fred", "query":"mycelium"}
UriTemplate.expand("http://{domain}/~{user}/foo{?query,number}", data)
// Returns http://example.com/~fred/foo?query=mycelium

// ..or use `Template` constructor
var template = new UriTemplate("http://{domain}/~{user}/foo{?query,number}")
template.expand({"domain":"example.com", "user":"fred", "query":"mycelium", "number": 3})
// Returns http://example.com/~fred/foo?query=mycelium&number=3

// Extract variables
template.match("http://example.com/~fred/foo?query=mycelium&number=3")
// Returns {"domain":"example.com", "user":"fred", "query":"mycelium", "number": "3"}

template.match("http://other.com/?query=mycelium")
// Returns null
```



About error handling
--------------------

This implementation tries to do a best effort template expansion
and leaves erroneous expressions in the returned URI
instead of throwing errors.
So for example, the incorrect expression
{unclosed will return {unclosed as output.



Browser Support
---------------

It should work IE6 and up but automated testing is currently broken.

-   For older browsers it requires `browser-upgrade-lite` package
    or other ES5 polyfill.
-   FF3-4 `escape` should be patched to remove non-standard 2nd param,
    `browser-upgrade-lite` does that.



## External links

[GitHub repo](https://github.com/litejs/uri-template-lite) |
[npm package](https://npmjs.org/package/uri-template-lite) |
URI Template [RFC 6570][] and
[Tests](https://github.com/uri-templates/uritemplate-test) |
[Coveralls coverage][2]  
[Buy Me A Tea][6]


## Licence

Copyright (c) 2014-2022 Lauri Rooden &lt;lauri@rooden.ee&gt;  
[The MIT License](http://lauri.rooden.ee/mit-license.txt)

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