Skip to content

Commit b5f3224

Browse files
committed
fix: fix hideHostname also hiding basePath
fixes #677
1 parent a69c402 commit b5f3224

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/Endpoint/Endpoint.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { OperationModel } from '../../services';
44
import { OptionsContext } from '../OptionsProvider';
55
import { SelectOnClick } from '../SelectOnClick/SelectOnClick';
66

7+
import { getBasePath } from '../../utils';
78
import {
89
EndpointInfo,
910
HttpVerb,
@@ -63,7 +64,11 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
6364
<div>{server.description}</div>
6465
<SelectOnClick>
6566
<ServerUrl>
66-
{!(hideHostname || options.hideHostname) && <span>{server.url}</span>}
67+
<span>
68+
{hideHostname || options.hideHostname
69+
? getBasePath(server.url)
70+
: server.url}
71+
</span>
6772
{operation.path}
6873
</ServerUrl>
6974
</SelectOnClick>

src/utils/helpers.ts

+4
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,7 @@ export function resolveUrl(url: string, to: string) {
161161
}
162162
return stripTrailingSlash(res);
163163
}
164+
165+
export function getBasePath(serverUrl: string): string {
166+
return new URL(serverUrl).pathname;
167+
}

0 commit comments

Comments
 (0)