mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
fix: remove trailing slash from url when use x-servers
This commit is contained in:
parent
bb3667d5d6
commit
2760a3410b
|
@ -2,6 +2,7 @@
|
||||||
import { Component, ChangeDetectionStrategy, Input, OnInit, HostListener, HostBinding} from '@angular/core';
|
import { Component, ChangeDetectionStrategy, Input, OnInit, HostListener, HostBinding} from '@angular/core';
|
||||||
import { BaseComponent, SpecManager } from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import { OptionsService } from '../../services/';
|
import { OptionsService } from '../../services/';
|
||||||
|
import { stripTrailingSlash } from '../../utils/';
|
||||||
|
|
||||||
export interface ServerInfo {
|
export interface ServerInfo {
|
||||||
description: string;
|
description: string;
|
||||||
|
@ -36,7 +37,7 @@ export class EndpointLink implements OnInit {
|
||||||
if (servers) {
|
if (servers) {
|
||||||
this.servers = servers.map(({url, description}) => ({
|
this.servers = servers.map(({url, description}) => ({
|
||||||
description,
|
description,
|
||||||
url: url.startsWith('//') ? `${this.specMgr.apiProtocol}:${url}` : url
|
url: stripTrailingSlash(url.startsWith('//') ? `${this.specMgr.apiProtocol}:${url}` : url)
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
this.servers = [
|
this.servers = [
|
||||||
|
|
|
@ -20,6 +20,10 @@ export function isBlank(obj: any): boolean {
|
||||||
return obj == undefined;
|
return obj == undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function stripTrailingSlash(path:string):string {
|
||||||
|
return path.endsWith('/') ? path.substring(0, path.length - 1) : path;
|
||||||
|
}
|
||||||
|
|
||||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
export function groupBy<T>(array: T[], key:string):StringMap<T[]> {
|
export function groupBy<T>(array: T[], key:string):StringMap<T[]> {
|
||||||
return array.reduce<StringMap<T[]>>(function(res, value) {
|
return array.reduce<StringMap<T[]>>(function(res, value) {
|
||||||
|
@ -119,7 +123,7 @@ export function isJsonLike(contentType: string): boolean {
|
||||||
return contentType.search(/json/i) !== -1;
|
return contentType.search(/json/i) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJsonLike(object: object) {
|
export function getJsonLike(object: Object) {
|
||||||
const jsonLikeKeys = Object.keys(object).filter(isJsonLike);
|
const jsonLikeKeys = Object.keys(object).filter(isJsonLike);
|
||||||
|
|
||||||
if (!jsonLikeKeys.length) {
|
if (!jsonLikeKeys.length) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user