@withjoy/sdk-js
Version:
Joy Javascript SDK
82 lines (81 loc) • 2.47 kB
TypeScript
export interface IUrl {
url: string;
path: string;
}
export interface IUrlObject {
hash?: string;
host?: string;
hostname?: string;
href?: string;
origin?: string;
pathname?: string;
port?: string;
protocol?: string;
search?: string;
routePrefix?: string;
}
export declare class Url {
static getCurrent(): string;
/**
* Parse a url so that its components can be accessed individually, from:
* http://stackoverflow.com/questions/6644654/ but modified so it doesn't
* retain the HTML anchor elements (no orphaned DOM nodes).
*
* @param {String} path
* @returns {IUrlObject}
*/
static parse(path: string): IUrlObject;
static parseSearch(search: string): any;
/**
* Build a url string from an object of url properties.
*
* @param {IUrlObject} obj
* @returns {string}
*/
static build(obj: IUrlObject): string;
/**
* Join all arguments together into a URL string. Removes duplicate slashes
* (but leaves the double slashes in a protocol, eg: http://foo/bar/baz).
*
* @param args
* @returns {String}
*/
static join(...args: any[]): string;
/**
* Serialize an object into a URL-friendly key1=val1&key2=val2 string.
*
* @param {Object} obj
* @returns {String}
*/
static param(obj: Object): string;
/**
* Create an absolute URL from a given path. If the path is already
* absolute then it is returned as it is. Otherwise the path is made
* absolute using a base URL or current URL if base is not provided.
*
* @param {String} path
* @param {String} [base]
* @returns {String}
*/
static absolute(path: string, base?: string): string;
/**
* Wrap a URL in slashes, ensuring no double slashes. Is careful not
* to destroy search parameters.
*
* Example:
* Url.wrapSlashes('foo/bar?baz=123'); -> '/foo/bar/?baz=123'
*
* @param {String} url
* @param {Boolean} last
* @param {Boolean} first
* @returns {string}
*/
static wrapSlashes(url: string, last?: boolean, first?: boolean): string;
/**
* Remove double slashes from a url except when used in a protocol (https://).
*
* @param {String} url
* @returns {String}
*/
static cleanSlashes(url: any): string;
}