Gathering detailed insights and metrics for uri-templates
Gathering detailed insights and metrics for uri-templates
Gathering detailed insights and metrics for uri-templates
Gathering detailed insights and metrics for uri-templates
npm install uri-templates
Typescript
Module System
Node Version
NPM Version
99.1
Supply Chain
99.2
Quality
75.5
Maintenance
100
Vulnerability
99.1
License
JavaScript (97.41%)
CSS (2.59%)
Total Downloads
71,885,725
Last Day
20,651
Last Week
296,912
Last Month
1,181,133
Last Year
26,222,402
141 Stars
34 Commits
18 Forks
6 Watchers
1 Branches
3 Contributors
Updated on Mar 14, 2025
Minified
Minified + Gzipped
Latest Version
0.2.0
Package Id
uri-templates@0.2.0
Size
42.75 kB
NPM Version
3.3.12
Node Version
5.5.0
Published on
May 29, 2016
Cumulative downloads
Total Downloads
Last Day
-22.4%
20,651
Compared to previous day
Last Week
1%
296,912
Compared to previous week
Last Month
13.5%
1,181,133
Compared to previous month
Last Year
32.9%
26,222,402
Compared to previous year
URI Templates (RFC6570) in JavaScript, including de-substitution.
It is tested against the official test suite, including the extended tests.
The "de-substitution" extracts parameter values from URIs. It is also tested against the official test suite (including extended tests).
In Node:
1var uriTemplates = require('uri-templates'); 2var template1 = uriTemplates("/date/{colour}/{shape}/");
In browser:
1var template2 = new UriTemplate("/prefix/{?params*}");
1// "/categories/green/round/" 2var uri1 = template1.fill({colour: "green", shape: "round"}); 3 4// "/prefix/?a=A&b=B&c=C 5var uri2 = template2.fillFromObject({ 6 params: {a: "A", b: "B", c: "C"} 7});
1// "/categories/example_colour/example_shape/" 2var uri1b = template1.fill(function (varName) { 3 return "example_" + varName; 4});
1var uri2b = "/prefix/?beep=boop&bleep=bloop"; 2var params = template2.fromUri(url2b); 3/* 4 { 5 params: { 6 beep: "boop", 7 bleep: "bloop" 8 } 9 } 10*/
While templates can be ambiguous (e.g. "{var1}{var2}"
), it will still produce something that reconstructs into the original URI.
It can handle all the cases in the official test suite, including the extended tests:
1var template = uriTemplate("{/id*}{?fields,token}"); 2 3var values = template.fromUri("/person/albums?fields=id,name,picture&token=12345"); 4/* 5{ 6 id: ["person", 'albums"], 7 fields: ["id", "name", "picture"], 8 token: "12345" 9} 10*/
strict
optionSometimes, you might want a more exact match, instead of a best guess. For example, this could be useful when using URI Templates for routing.
The strict
option performs more checks, to see whether the URI being matched is plausible:
1var template = uriTemplate("/prefix/{value}/{suffix}"); 2 3// Matches, even though "foo/bar" contains a "/" which is not allowed 4var looseMatch = template.fromUri('/prefix/foo/bar/suffix'); 5// Does not match 6var strictMatch = template.fromUri('/prefix/foo/bar/suffix', {strict: true}); 7
1var uri2b = "/prefix/?beep=boop&bleep=bloop"; 2var isMatch = template2.test(url2b); // === true
This returns a boolean, and takes the same options as .fromUri()
.
This project is released as public-domain. Anybody can modify or re-license it for any purpose, without restriction.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 3/29 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
55 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More