chore: revert "fix: operation url in static page (#2093)" (#2094)

This reverts commit 98eec19647.
This commit is contained in:
Alex Varchuk 2022-07-22 17:15:34 +03:00 committed by GitHub
parent 98eec19647
commit d7a1ec11d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 18 deletions

View File

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

View File

@ -175,15 +175,6 @@ export function getBasePath(serverUrl: string): string {
}
}
export function getBaseUrl(serverUrl: string): string {
try {
return parseURL(serverUrl).origin;
} catch (e) {
// when using with redoc-cli serverUrl can be empty resulting in crash
return serverUrl;
}
}
export function titleize(text: string) {
return text.charAt(0).toUpperCase() + text.slice(1);
}

View File

@ -16,7 +16,7 @@ import {
Referenced,
} from '../types';
import { IS_BROWSER } from './dom';
import { isNumeric, resolveUrl, isArray, isBoolean, getBaseUrl } from './helpers';
import { isNumeric, removeQueryString, resolveUrl, isArray, isBoolean } from './helpers';
function isWildcardStatusCode(statusCode: string | number): statusCode is string {
return typeof statusCode === 'string' && /\dxx/i.test(statusCode);
@ -606,7 +606,8 @@ export function normalizeServers(
return href.endsWith('.html') ? dirname(href) : href;
};
const baseUrl = specUrl === undefined ? getBaseUrl(getHref()) : dirname(specUrl);
const baseUrl = specUrl === undefined ? removeQueryString(getHref()) : dirname(specUrl);
if (servers.length === 0) {
// Behaviour defined in OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#openapi-object
servers = [