# es6-url-template

> This is a simple URI template implementation following the [RFC 6570 URI Template specification](http://tools.ietf.org/html/rfc6570). The implementation supports all levels defined in the specification and is extensively tested.

Latest version **3.0.2** (published 2020-10-16) · BSD license · 0 weekly downloads

## Install

```sh
npm install es6-url-template
pnpm add es6-url-template
yarn add es6-url-template
bun add es6-url-template
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2020-10-16 |
| First published | 2017-11-27 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Bram Stein |
| Maintainers | tpluscode |
| Keywords | uri-template, uri template, uri, url, rfc 6570, url template, url-template |

## Links

- npm: https://www.npmjs.com/package/es6-url-template
- Repository: https://github.com/wikibus/es6-url-template
- Homepage: https://github.com/wikibus/es6-url-template#readme
- Issues: https://github.com/wikibus/es6-url-template/issues
- npm.io page: https://npm.io/package/es6-url-template

## 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

- 3.0.2 (latest) — 2020-10-16
- 3.0.1 — 2020-10-13
- 3.0.0 — 2020-10-12
- 1.0.4 — 2020-08-04
- 1.0.3 — 2018-10-30
- 1.0.2 — 2018-10-30
- 1.0.1 — 2018-10-30
- 1.0.0 — 2017-11-27

## README

## An ES6 URI template implementation

This is a simple URI template implementation following the [RFC 6570 URI Template specification](http://tools.ietf.org/html/rfc6570). The implementation supports all levels defined in the specification and is extensively tested.

This is a fork of `url-template` changed to use ES6 classes and exported as a module.

## Installation

```sh
$ yarn add es6-url-template
```

## Example

```js
import UriTemplate from 'es6-url-template';

const emailUrlTemplate = new UriTemplate('/{email}/{folder}/{id}');
const emailUrl = emailUrlTemplate.expand({
  email: 'user@domain',
  folder: 'test',
  id: 42
});

console.log(emailUrl);
// Returns '/user@domain/test/42'
```

## A note on error handling and reporting

The RFC states that errors in the templates could optionally be handled and reported to the user. This implementation takes a slightly different approach in that it 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. The leaves incorrect URLs to be handled by your URL library of choice.

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