mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 16:46:25 +00:00
19 lines
450 B
TypeScript
19 lines
450 B
TypeScript
import urlJoin from 'url-join';
|
|
|
|
export function ensureTrailingSlash(url: string): string {
|
|
return url.replace(/\/?$/, '/');
|
|
}
|
|
|
|
export function resolveBaseUrl(baseUrl: string, input: string | URL): string {
|
|
const inputString = input.toString();
|
|
|
|
let host;
|
|
let pathname;
|
|
try {
|
|
({ host, pathname } = new URL(inputString));
|
|
} catch (e) {
|
|
pathname = inputString;
|
|
}
|
|
|
|
return host ? inputString : urlJoin(baseUrl, pathname || '');
|
|
}
|