Skip to content

Commit

Permalink
fix: fix hideHostname also hiding basePath
Browse files Browse the repository at this point in the history
fixes #677
  • Loading branch information
RomanHotsiy committed Nov 5, 2018
1 parent a69c402 commit b5f3224
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Endpoint/Endpoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { OperationModel } from '../../services';
import { OptionsContext } from '../OptionsProvider';
import { SelectOnClick } from '../SelectOnClick/SelectOnClick';

import { getBasePath } from '../../utils';
import {
EndpointInfo,
HttpVerb,
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit b5f3224

Please sign in to comment.