UNPKG

@mollie/api-client

Version:
16 lines (15 loc) 835 B
export type SearchParameters = Record<string, any>; /** * Builds a URL from the passed origin+pathname and search parameters. For example: `https://example.com` and * `{ id: 5 }` is converted to `https://example.com?id=5`; while `https://example.com` and `undefined` is left as * `https://example.com`. * * Note that the origin+pathname is used verbatim. The origin is optional and a relative URL can be built by omitting * it. * * As expected by the Mollie API: * * search parameters which are arrays are joined with commas (`{ array: [1, 2] }` becomes `?array=1,2`), and * * search parameters which are objects (but not arrays) are flattened (`{ object: { key: 'value' } }` becomes * `?object[key]=value`). */ export default function buildUrl(originAndPathname: string, searchParameters?: SearchParameters): string;