UrlParser
URL parser.
Example:
const urlparser = new UrlParser('http://example.com/api/people?name=Jane');
urlparser.queryString.set('search', 'doe');
// urlparser.buildUrl() === 'http://example.com/api/people?name=Jane&search=doe'
Static Method Summary
Static Public Methods | ||
public static |
Join URL paths. |
Constructor Summary
Public Constructor | ||
public |
constructor(url: *) |
Member Summary
Public Members | ||
public get |
domain: * |
|
public get |
path: * |
|
public |
The query-string of the the URL. |
|
public get |
scheme: * |
Method Summary
Public Methods | ||
public |
Build the URL. |
|
public |
deepCopy(): * Create a deep copy of this UrlParser object. |
|
public |
setQueryString(queryStringObject: QueryString) Set/replace the query-string. |
Static Public Methods
public static pathJoin(firstPath: *, paths: *): string source
Join URL paths.
Params:
Name | Type | Attribute | Description |
firstPath | * | The first path. Can be an URL. |
|
paths | * | Paths to join with the first path. |
Example:
UrlParser.pathJoin('/test', 'user/') // == '/test/user/'
UrlParser.pathJoin('/test/', 'user/') // == '/test/user/'
UrlParser.pathJoin('/test/', '/user/') // == '/test/user/'
UrlParser.pathJoin('/test') // == '/test'
UrlParser.pathJoin('http://example.com/test/', '/user/', 10) // == http://example.com/test/user/10
Public Constructors
public constructor(url: *) source
Params:
Name | Type | Attribute | Description |
url | * |
Public Methods
public setQueryString(queryStringObject: QueryString) source
Set/replace the query-string.
Params:
Name | Type | Attribute | Description |
queryStringObject | QueryString | The QueryString object to replace the current query-string with. |
Example:
const urlparser = UrlParser('http://example.com/api/people');
const querystring = new QueryString();
querystring.set('search', 'doe');
urlparser.setQueryString(querystring);
// urlparser.buildUrl() === 'http://example.com/api/people?search=doe'