{"id":17087855,"url":"https://github.com/geraintluff/uri-templates","last_synced_at":"2025-04-04T11:10:41.462Z","repository":{"id":9988165,"uuid":"12018271","full_name":"geraintluff/uri-templates","owner":"geraintluff","description":"JavaScript utility for RFC 6570: URI Templates","archived":false,"fork":false,"pushed_at":"2024-01-14T16:34:30.000Z","size":80,"stargazers_count":141,"open_issues_count":15,"forks_count":21,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T10:05:59.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geraintluff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-10T08:57:33.000Z","updated_at":"2025-03-14T17:59:34.000Z","dependencies_parsed_at":"2024-01-14T15:56:16.467Z","dependency_job_id":"5b4465e2-38b7-47cb-9fe5-d6e8df1bb8bf","html_url":"https://github.com/geraintluff/uri-templates","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":"0.10344827586206895","last_synced_commit":"062e7ae57b926899ac865e67cb56826255d05011"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Furi-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Furi-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Furi-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Furi-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geraintluff","download_url":"https://codeload.github.com/geraintluff/uri-templates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166168,"owners_count":20894654,"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":"2024-10-14T13:35:10.325Z","updated_at":"2025-04-04T11:10:41.444Z","avatar_url":"https://github.com/geraintluff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uri-templates\n\nURI Templates ([RFC6570](http://tools.ietf.org/html/rfc6570)) in JavaScript, including de-substitution.\n\nIt is tested against the [official test suite](https://github.com/uri-templates/uritemplate-test), including the extended tests.\n\nThe \"de-substitution\" extracts parameter values from URIs.  It is also tested against the official test suite (including extended tests).\n\n## Creation\n\nIn Node:\n```javascript\nvar uriTemplates = require('uri-templates');\nvar template1 = uriTemplates(\"/date/{colour}/{shape}/\");\n```\n\nIn browser:\n```javascript\nvar template2 = new UriTemplate(\"/prefix/{?params*}\");\n```\n\n## Substitution using an object\n```javascript\n// \"/categories/green/round/\"\nvar uri1 = template1.fill({colour: \"green\", shape: \"round\"});\n\n// \"/prefix/?a=A\u0026b=B\u0026c=C\nvar uri2 = template2.fillFromObject({\n\tparams: {a: \"A\", b: \"B\", c: \"C\"}\n});\n```\n\n## Substitution using a callback\n```javascript\n// \"/categories/example_colour/example_shape/\"\nvar uri1b = template1.fill(function (varName) {\n\treturn \"example_\" + varName;\n});\n```\n\n## Guess variables from URI (\"de-substitution\")\n```javascript\nvar uri2b = \"/prefix/?beep=boop\u0026bleep=bloop\";\nvar params = template2.fromUri(uri2b);\n/*\n\t{\n\t\tparams: {\n\t\t\tbeep: \"boop\",\n\t\t\tbleep: \"bloop\"\n\t\t}\n\t}\n*/\n```\n\nWhile templates can be ambiguous (e.g. `\"{var1}{var2}\"`), it will still produce *something* that reconstructs into the original URI.\n\nIt can handle all the cases in the official test suite, including the extended tests:\n\n```javascript\nvar template = uriTemplate(\"{/id*}{?fields,token}\");\n\nvar values = template.fromUri(\"/person/albums?fields=id,name,picture\u0026token=12345\");\n/*\n{\n\tid: [\"person\", 'albums\"],\n\tfields: [\"id\", \"name\", \"picture\"],\n\ttoken: \"12345\"\n}\n*/\n```\n\n## License\n\nThis project is released as [public-domain](http://geraintluff.github.io/tv4/LICENSE.txt).  Anybody can modify or re-license it for any purpose, without restriction.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Furi-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeraintluff%2Furi-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Furi-templates/lists"}