File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -163,17 +163,27 @@ export function resolveUrl(url: string, to: string) {
163
163
}
164
164
165
165
export function getBasePath ( serverUrl : string ) : string {
166
- return parseURL ( serverUrl ) . pathname ;
166
+ try {
167
+ return parseURL ( serverUrl ) . pathname ;
168
+ } catch ( e ) {
169
+ // when using with redoc-cli serverUrl can be empty resulting in crash
170
+ return serverUrl ;
171
+ }
167
172
}
168
173
169
174
export function titleize ( text : string ) {
170
175
return text . charAt ( 0 ) . toUpperCase ( ) + text . slice ( 1 ) ;
171
176
}
172
177
173
178
export function removeQueryString ( serverUrl : string ) : string {
174
- const url = parseURL ( serverUrl ) ;
175
- url . search = '' ;
176
- return url . toString ( ) ;
179
+ try {
180
+ const url = parseURL ( serverUrl ) ;
181
+ url . search = '' ;
182
+ return url . toString ( ) ;
183
+ } catch ( e ) {
184
+ // when using with redoc-cli serverUrl can be empty resulting in crash
185
+ return serverUrl ;
186
+ }
177
187
}
178
188
179
189
function parseURL ( url : string ) {
You can’t perform that action at this time.
0 commit comments