mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-04 12:20:19 +03:00
fix: correct URLs of OperationModel servers
This commit is contained in:
parent
9920991080
commit
8db7cc92bb
|
@ -179,10 +179,11 @@ export function titleize(text: string) {
|
||||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeQueryString(serverUrl: string): string {
|
export function removeQueryStringAndHash(serverUrl: string): string {
|
||||||
try {
|
try {
|
||||||
const url = parseURL(serverUrl);
|
const url = parseURL(serverUrl);
|
||||||
url.search = '';
|
url.search = '';
|
||||||
|
url.hash = '';
|
||||||
return url.toString();
|
return url.toString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// when using with redoc-cli serverUrl can be empty resulting in crash
|
// when using with redoc-cli serverUrl can be empty resulting in crash
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
Referenced,
|
Referenced,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { IS_BROWSER } from './dom';
|
import { IS_BROWSER } from './dom';
|
||||||
import { isNumeric, removeQueryString, resolveUrl, isArray, isBoolean } from './helpers';
|
import { isNumeric, removeQueryStringAndHash, resolveUrl, isArray, isBoolean } from './helpers';
|
||||||
|
|
||||||
function isWildcardStatusCode(statusCode: string | number): statusCode is string {
|
function isWildcardStatusCode(statusCode: string | number): statusCode is string {
|
||||||
return typeof statusCode === 'string' && /\dxx/i.test(statusCode);
|
return typeof statusCode === 'string' && /\dxx/i.test(statusCode);
|
||||||
|
@ -602,7 +602,7 @@ export function normalizeServers(
|
||||||
return href.endsWith('.html') ? dirname(href) : href;
|
return href.endsWith('.html') ? dirname(href) : href;
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseUrl = specUrl === undefined ? removeQueryString(getHref()) : dirname(specUrl);
|
const baseUrl = specUrl === undefined ? removeQueryStringAndHash(getHref()) : dirname(specUrl);
|
||||||
|
|
||||||
if (servers.length === 0) {
|
if (servers.length === 0) {
|
||||||
// Behaviour defined in OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#openapi-object
|
// Behaviour defined in OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#openapi-object
|
||||||
|
|
Loading…
Reference in New Issue
Block a user