refactor: call getBasePath function once

This commit is contained in:
Anya Stasiuk 2020-11-03 14:32:34 +02:00
parent 36deecacfd
commit 0dcff6eb46

View File

@ -67,7 +67,7 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
const normalizedUrl = options.expandDefaultServerVariables const normalizedUrl = options.expandDefaultServerVariables
? expandDefaultServerVariables(server.url, server.variables) ? expandDefaultServerVariables(server.url, server.variables)
: server.url; : server.url;
const basePath = getBasePath(normalizedUrl) === '/' ? '' : getBasePath(normalizedUrl); const basePath = getBasePath(normalizedUrl);
return ( return (
<ServerItem key={normalizedUrl}> <ServerItem key={normalizedUrl}>
<Markdown source={server.description || ''} compact={true} /> <Markdown source={server.description || ''} compact={true} />
@ -75,7 +75,9 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
<ServerUrl> <ServerUrl>
<span> <span>
{hideHostname || options.hideHostname {hideHostname || options.hideHostname
? basePath ? basePath === '/'
? ''
: basePath
: normalizedUrl} : normalizedUrl}
</span> </span>
{operation.path} {operation.path}