fix: fix hideHostname also hiding basePath

fixes #677
This commit is contained in:
Roman Hotsiy 2018-11-05 15:53:42 +02:00
parent a69c402d9b
commit b5f32247be
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 10 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { OperationModel } from '../../services';
import { OptionsContext } from '../OptionsProvider';
import { SelectOnClick } from '../SelectOnClick/SelectOnClick';
import { getBasePath } from '../../utils';
import {
EndpointInfo,
HttpVerb,
@ -63,7 +64,11 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
<div>{server.description}</div>
<SelectOnClick>
<ServerUrl>
{!(hideHostname || options.hideHostname) && <span>{server.url}</span>}
<span>
{hideHostname || options.hideHostname
? getBasePath(server.url)
: server.url}
</span>
{operation.path}
</ServerUrl>
</SelectOnClick>

View File

@ -161,3 +161,7 @@ export function resolveUrl(url: string, to: string) {
}
return stripTrailingSlash(res);
}
export function getBasePath(serverUrl: string): string {
return new URL(serverUrl).pathname;
}