# @contentgrid/uri-template

> RFC6570 URI template parser and expander

Latest version **0.4.2** (published 2025-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @contentgrid/uri-template
pnpm add @contentgrid/uri-template
yarn add @contentgrid/uri-template
bun add @contentgrid/uri-template
```

## Health

**Score 55/100 (C)** — status: stable.

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

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2025-03-24 |
| First published | 2023-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | xenit-jenkins |
| Keywords | RFC6570, uri-template, uri |

## Links

- npm: https://www.npmjs.com/package/@contentgrid/uri-template
- Repository: https://github.com/xenit-eu/contentgrid-ts
- npm.io page: https://npm.io/package/@contentgrid/uri-template

## Dependencies (4)

- [tslib](https://npm.io/package/tslib.md) ^2.6.1
- [uri-templates](https://npm.io/package/uri-templates.md) ^0.2.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.22.6
- [@types/uri-templates](https://npm.io/package/@types/uri-templates.md) ^0.1.31

## Recent versions

- 0.4.2 (latest) — 2025-03-24
- 0.4.1 — 2024-10-18
- 0.4.0 — 2024-07-08
- 0.3.0 — 2024-04-03
- 0.2.0 — 2023-09-28
- 0.1.0 — 2023-08-09
- 0.0.1-alpha.6 — 2023-08-08
- 0.0.1-alpha.5 — 2023-08-08
- 0.0.1-alpha.0 — 2023-08-07

## README

# `@contentgrid/uri-template`

[RFC 6570](https://datatracker.ietf.org/doc/html/rfc6570) compliant URI template parser and expander.

## Usage

```typescript
import UriTemplate from '@contentgrid/uri-template'

const template = new UriTemplate("http://example.com/{resource}/search{?color,height}");


// Expand using named keys
template.expand({ resource: "cars" }) // -> "http://example.com/cars/search"

// Expand using positional keys
template.expand(["cars", "blue"]) // -> "http://example.com/cars/search?color=blue"

// Parsing URLs
template.match("http://example.com/cars/search") // -> { resource: "cars" }
template.match("http://example.org/something-else") // -> null

```

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