UNPKG

1.15 kBTypeScriptView Raw
1/**
2 * A collection of utilities for working with URLs
3 * @module URLUtils
4 *
5 * @example
6 * const { buildURL } = require('@cumulus/common/URLUtils');
7 *
8 * buildURL({ protocol: 'http', host: 'example.com' }); // => 'http://example.com'
9 */
10/**
11 * Build a URL
12 *
13 * @param {Object} params - URL parameters
14 * @param {string} params.protocol - the protocol ('http', 'ftp', 's3', etc)
15 * @param {string} params.host - the host
16 * @param {string|integer} [params.port] - the port
17 * @param {string|string[]} [params.path] - path segment(s) to add to the end of
18 * the URL. Can be either a string or an array of strings, which will be
19 * joined together.
20 * @returns {string} a URL
21 * @throws {TypeError} if protocol or host are not specified
22 *
23 * @alias module:URLUtils
24 *
25 * @example
26 * buildURL({
27 * protocol: 'http'
28 * host: 'example.com',
29 * port: 8080,
30 * path: ['path', 'to', 'file.txt']
31 * }); // => 'http://example.com:8080/path/to/file.txt'
32 */
33export declare const buildURL: (params: {
34 protocol: string;
35 host: string;
36 port?: string;
37 path?: string | string[];
38}) => string;
39//# sourceMappingURL=URLUtils.d.ts.map
\No newline at end of file