url-lib
Version:
A simple, lightweight string utility for Node and browsers that supports serializing and parsing URLs and query strings.
38 lines (37 loc) • 2.14 kB
TypeScript
import { NullableUrlParams } from './types';
declare type UrlPathAndParams = [string, ...NullableUrlParams[]];
/**
* Serializes the specified URL path with properties of a params object to produce a URL.
* @param {string} [urlPath] - Base URL path
* @param {NullableUrlParams} [urlParams] - Query params to combine with base URL
* @returns {string} Serialized URL
*/
declare function formatUrl(urlPath?: string, urlParams?: NullableUrlParams): string;
/**
* Serializes the specified URL path with properties of a params object to produce a URL.
* @param {string} urlPath - Base URL path
* @param {NullableUrlParams[]} urlParamsList - Multiple query params to merge and then combine with base URL
* @returns {string} Serialized URL
*/
declare function formatUrl(urlPath: string, urlParamsList: NullableUrlParams[]): string;
/**
* Serializes the specified URL path with properties of a params object to produce a URL.
* @param {UrlPathAndParams} urlPathAndParamsTuple - Tuple of base URL path + one or more query params to combine with base URL
* @returns {string} Serialized URL
*/
declare function formatUrl(urlPathAndParamsTuple: UrlPathAndParams): string;
/**
* Serializes the specified URL path with properties of a params object to produce a URL.
* @param {UrlPathAndParams} urlPathAndParamsTuple - Tuple of base URL path + one or more query params to combine with base URL
* @param {NullableUrlParams} urlParams - More query params to combine with `urlPathAndParamsTuple`
* @returns {string} Serialized URL
*/
declare function formatUrl(urlPathAndParamsTuple: UrlPathAndParams, urlParams: NullableUrlParams): string;
/**
* Serializes the specified URL path with properties of a params object to produce a URL.
* @param {UrlPathAndParams} urlPathAndParamsTuple - Tuple of base URL path + one or more query params to combine with base URL
* @param {NullableUrlParams[]} urlParamsList - Multiple query params to merge and then combine with `urlPathAndParamsTuple`
* @returns {string} Serialized URL
*/
declare function formatUrl(urlPathAndParamsTuple: UrlPathAndParams, urlParamsList: NullableUrlParams[]): string;
export default formatUrl;