build-url-ts
Version:
A small library that builds a URL given its components
32 lines • 1.32 kB
TypeScript
export type QueryParamValue = null | undefined | string | number | boolean | (string | number | boolean | null | undefined)[] | Date | object;
export type IQueryParams = Record<string, QueryParamValue>;
export type IDisableCsvType = 'array' | 'order_asc' | 'order_desc';
export interface IBuildUrlOptions {
path?: string | number;
lowerCase?: boolean;
queryParams?: IQueryParams;
disableCSV?: boolean | IDisableCsvType;
hash?: string | number;
}
/**
* Builds a query string from parameters
*/
export declare function buildQueryString(queryParams: IQueryParams, lowerCase?: boolean, disableCSV?: boolean | IDisableCsvType, useCustomEncoding?: boolean): string;
/**
* Appends a path segment to a URL
*/
export declare function appendPath(path: string | number, builtUrl: string, lowerCase?: boolean): string;
/**
* Builds a hash fragment for a URL
*/
export declare function buildHash(hash: string | number, lowerCase?: boolean): string;
/**
* Builds a complete URL from components
* @param url - Base URL or options object
* @param options - URL building options
* @returns The constructed URL string
*/
declare function buildUrl(url?: string | null | IBuildUrlOptions, options?: IBuildUrlOptions): string;
export { buildUrl };
export default buildUrl;
//# sourceMappingURL=index.d.ts.map