@eclipse-scout/core
Version:
Eclipse Scout runtime
58 lines • 2.17 kB
TypeScript
/**
* Input is expected to be encoded. Output (toString()) is also encoded.
* If no URL is passed, 'window.location.href' is used as input.
*/
export declare class URL {
baseUrlRaw: string;
queryPartRaw: string;
hashPartRaw: string;
parameterMap: Record<string, string | string[]>;
constructor(url?: string);
/**
* Checks if the given parameter exists, even if value is null or an empty string.
*/
hasParameter(param: string): boolean;
getParameter(param: string): string | string[];
removeParameter(param: string): URL;
setParameter(param: string, value?: string | string[]): URL;
addParameter(param: string, value?: string): URL;
toString(options?: UrlToStringOptions): string;
clone(): URL;
/**
* Helper function to sort arrays alphabetically, nulls in front
*/
protected static _sorter(a: string, b: string): number;
/**
* Helper function to build a query parameter with value
*/
protected static _formatQueryParam(key: string, value?: string): string;
/**
* Helper function to add an key-value pair to a map. If the key is added multiple
* times, the value is converted to an array.
*
* @memberOf URL
*/
protected static _addToMap(map: Record<string, string | string[]>, key: string, value?: string): void;
/**
* Helper function to parse the given (encoded) query string and return
* it as (un-encoded) map of key-value pairs.
*
* @memberOf URL
*/
protected static _parse(queryPart: string): Record<string, string | string[]>;
}
export interface UrlToStringOptions {
/**
* a function to be used instead of the default lexical ordering based function
*/
sorter?: (a: string, b: string) => number;
/**
* an array of parameter names that should always be first in the resulting string. Among those parameters, the order in the passed array is respected.
*/
alwaysFirst?: string | string[];
/**
* similar to alwaysFirst, but puts the parameters at the end of the resulting string.
*/
alwaysLast?: string | string[];
}
//# sourceMappingURL=URL.d.ts.map