mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 01:54:08 +03:00
fix: crash with empty servers with redoc-cli
This commit is contained in:
parent
3ae62f1d5d
commit
3d52b39274
|
@ -163,7 +163,12 @@ export function resolveUrl(url: string, to: string) {
|
|||
}
|
||||
|
||||
export function getBasePath(serverUrl: string): string {
|
||||
return parseURL(serverUrl).pathname;
|
||||
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 {
|
||||
const url = parseURL(serverUrl);
|
||||
url.search = '';
|
||||
return url.toString();
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user