From b5f32247bec3b4225c9f0e694a2a744c28e84a6d Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 5 Nov 2018 15:53:42 +0200 Subject: [PATCH] fix: fix hideHostname also hiding basePath fixes #677 --- src/components/Endpoint/Endpoint.tsx | 7 ++++++- src/utils/helpers.ts | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Endpoint/Endpoint.tsx b/src/components/Endpoint/Endpoint.tsx index 734fa32b49..08e7f7b775 100644 --- a/src/components/Endpoint/Endpoint.tsx +++ b/src/components/Endpoint/Endpoint.tsx @@ -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 {
{server.description}
- {!(hideHostname || options.hideHostname) && {server.url}} + + {hideHostname || options.hideHostname + ? getBasePath(server.url) + : server.url} + {operation.path} diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 116390633d..699d3da523 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -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; +}