{"id":24976878,"url":"https://github.com/rezigned/uri-template.js","last_synced_at":"2025-04-11T14:13:17.023Z","repository":{"id":16676628,"uuid":"19432500","full_name":"rezigned/uri-template.js","owner":"rezigned","description":"Node.js/Javascript RFC 6570 URI Template implementation that supports both URI expansion and extraction.","archived":false,"fork":false,"pushed_at":"2020-07-30T15:05:38.000Z","size":93,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T10:21:32.505Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rezigned.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-04T18:11:54.000Z","updated_at":"2022-11-20T15:03:14.000Z","dependencies_parsed_at":"2022-08-25T20:22:10.155Z","dependency_job_id":null,"html_url":"https://github.com/rezigned/uri-template.js","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezigned%2Furi-template.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezigned%2Furi-template.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezigned%2Furi-template.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezigned%2Furi-template.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rezigned","download_url":"https://codeload.github.com/rezigned/uri-template.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248414995,"owners_count":21099585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-03T22:59:20.098Z","updated_at":"2025-04-11T14:13:17.003Z","avatar_url":"https://github.com/rezigned.png","language":"CoffeeScript","readme":"# uri-template.js\n\nNode.js/Javascript [RFC 6570 URI Template](http://tools.ietf.org/html/rfc6570) implementation that supports both URI expansion and extraction.\n\n[![Build Status](https://travis-ci.org/rezigned/uri-template.js.svg?branch=master)](https://travis-ci.org/rezigned/uri-template.js)\n\n* [PHP](https://github.com/rize/UriTemplate) URI Template\n\n## Usage\n### Expansion\n\nA very simple usage\n\n```js\nUriTemplate.expand('/{username}/profile', {'username': 'john'});\n\n\u003e\u003e '/john/profile'\n```\n\nMore examples (supports all expansion levels defined in RFC6570)\n```js\nUriTemplate.expand('/search/{term:1}/{term}/{?q*,limit}', {\n    term: 'john',\n    q: ['a', 'b'],\n    limit: 10,\n});\n\n\u003e\u003e '/search/j/john/?q=a,b\u0026limit=10'\n```\n\n### Extraction\n\nExtract variables from URI.\n\n```js\nUriTemplate.extract('/search/{term:1}/{term}/{?q*,limit}', '/search/j/john/?q=a\u0026q=b\u0026limit=10');\n\n\u003e\u003e\n(\n    'term:1': 'j',\n    term: 'john',\n    q: [\n      'a',\n      'b'\n    ]\n    limit: 10\n)\n```\n### UriTemplate class\n\nYou can also instantiate `UriTemplate` instance via `new` keyword. Its constructor accepts 2 optional params `base uri` and `default params`. Which is very useful when working with API endpoint.\n\n```js\nvar uri = new UriTemplate('https://api.twitter.com/{version}', {'version': 1.1});\nuri.expand('/statuses/show/{id}.json', {'id': '210462857140252672'});\n\n\u003e\u003e https://api.twitter.com/1.1/statuses/show/210462857140252672.json\n```\n\n## Installation\n\nIn browsers:\n\n```bash\nbower install uri-template.js\n```\n\n```html\n\u003cscript src=\"dist/uri-template.js\"\u003e\u003c/script\u003e\nUriTemplate.expand(...)\n```\n\nIn Node.js\n\n```bash\nnpm install uri-template.js\n\nUriTemplate = require('uri-template.js');\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezigned%2Furi-template.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frezigned%2Furi-template.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezigned%2Furi-template.js/lists"}