fix: crash with empty servers with redoc-cli

This commit is contained in:
Roman Hotsiy 2019-05-13 15:49:54 +03:00
parent 3ae62f1d5d
commit 3d52b39274
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -163,7 +163,12 @@ export function resolveUrl(url: string, to: string) {
}
export function getBasePath(serverUrl: string): string {
try {
return parseURL(serverUrl).pathname;
} catch (e) {
// when using with redoc-cli serverUrl can be empty resulting in crash
return serverUrl;
}
}
export function titleize(text: string) {
@ -171,9 +176,14 @@ export function titleize(text: string) {
}
export function removeQueryString(serverUrl: string): string {
try {
const url = parseURL(serverUrl);
url.search = '';
return url.toString();
} catch (e) {
// when using with redoc-cli serverUrl can be empty resulting in crash
return serverUrl;
}
}
function parseURL(url: string) {