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