GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - rezigned/uri-template.js: Node.js/Javascript RFC 6570 URI Template implementation that supports both URI expansion and extraction.

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bower.json
bower.json
 
 
component.json
component.json
 
 
gulpfile.coffee
gulpfile.coffee
 
 
index.js
index.js
 
 
package.json
package.json
 
 

Repository files navigation

uri-template.js

Node.js/Javascript RFC 6570 URI Template implementation that supports both URI expansion and extraction.

Build Status

  • PHP URI Template

Usage

Expansion

A very simple usage

UriTemplate.expand('/{username}/profile', {'username': 'john'});

>> '/john/profile'

More examples (supports all expansion levels defined in RFC6570)

UriTemplate.expand('/search/{term:1}/{term}/{?q*,limit}', {
    term: 'john',
    q: ['a', 'b'],
    limit: 10,
});

>> '/search/j/john/?q=a,b&limit=10'

Extraction

Extract variables from URI.

UriTemplate.extract('/search/{term:1}/{term}/{?q*,limit}', '/search/j/john/?q=a&q=b&limit=10');

>>
(
    'term:1': 'j',
    term: 'john',
    q: [
      'a',
      'b'
    ]
    limit: 10
)

UriTemplate class

You 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.

var uri = new UriTemplate('https://api.twitter.com/{version}', {'version': 1.1});
uri.expand('/statuses/show/{id}.json', {'id': '210462857140252672'});

>> https://api.twitter.com/1.1/statuses/show/210462857140252672.json

Installation

In browsers:

bower install uri-template.js
<script src="dist/uri-template.js"></script>
UriTemplate.expand(...)

In Node.js

npm install uri-template.js

UriTemplate = require('uri-template.js');

About

Node.js/Javascript RFC 6570 URI Template implementation that supports both URI expansion and extraction.

Resources

Readme
MIT license
Activity

Stars

8 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.