Uri

API ReferenceNetworkingUri

Source


constructor()

Parameters
  • uri — String

Represents an uri string with parameters.

The parameter must be wrapped by the curly brackets {…}.

Rest parameters are not greedy and are wrapped by the {…*} or just …*. Rest parameters don't have to be named ({*} is allowed).

var uri = new Networking.Uri('articles/{pageStart}/{pageEnd}');
console.log(uri.match('articles/2/4'));
// { pageStart: '2', pageEnd: '4' }

var uri = new Networking.Uri('comments/{path*}/{page}');
console.log(uri.match('comments/article/world/test-article/4'));
// { path: 'article/world/test-article', page: '4' }

Access it with:

var Networking = require('networking');
var Uri = Networking.Uri;

Source


protocol

Type
String

auth

Type
String

host

Type
String

path

Type
String

params

Type
Object

Holds the last Uri::match() result.


query

Type
Object

hash

Type
String

test()

Parameters
  • uri — String
Returns
Boolean

Test whether the uri is valid with the given string.

Source


match()

Parameters
  • uri — String
Returns
Object

Returns found parameters from the given string.

If the given uri is not valid with the uri, error will be raised.

Source


toString()

Parameters
  • params — Object|Dictoptional
Returns
String

Parses the uri into a string.

The given params object is used to replace the uri parameters.

var uri = new Networking.Uri('user/{name}');

console.log(uri.toString({name: 'Jane'}));
// /user/Jane

console.log(uri.toString());
// /user/{name}

Source

results matching ""

    No results matching ""