UNPKG

nyro

Version:

A simple and effective promise-based HTTP & HTTP/2 request library that supports all HTTP methods.

19 lines (18 loc) 678 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Combines a base URL with a relative URL, ensuring that there is exactly one slash between them. * * @param baseUrl - The base URL to which the relative URL will be appended. * @param url - The relative URL to append to the base URL. * @param path - The path to append to the combined URL. * @returns The combined URL as a string. */ function combineUrl(baseUrl, url, path) { var fullUrl = "".concat(baseUrl || '').concat(url || '').concat(path || ''); if (fullUrl.trim().endsWith('/')) fullUrl = fullUrl.slice(0, -1); return fullUrl; } ; exports.default = combineUrl;