From 186e7b96f0a887b20f96fc205cc7317a48c0123a Mon Sep 17 00:00:00 2001 From: Anto Date: Fri, 19 Apr 2019 15:18:14 +0200 Subject: [PATCH] Remove querystring from exposed URL --- src/components/Endpoint/Endpoint.tsx | 4 ++-- src/utils/helpers.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Endpoint/Endpoint.tsx b/src/components/Endpoint/Endpoint.tsx index 00d7bda060..bc7863d4c8 100644 --- a/src/components/Endpoint/Endpoint.tsx +++ b/src/components/Endpoint/Endpoint.tsx @@ -5,7 +5,7 @@ import { Markdown } from '../Markdown/Markdown'; import { OptionsContext } from '../OptionsProvider'; import { SelectOnClick } from '../SelectOnClick/SelectOnClick'; -import { getBasePath } from '../../utils'; +import {getBasePath, removeQueryString} from '../../utils'; import { EndpointInfo, HttpVerb, @@ -68,7 +68,7 @@ export class Endpoint extends React.Component { {hideHostname || options.hideHostname ? getBasePath(server.url) - : server.url} + : removeQueryString(server.url)} {operation.path} diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 699d3da523..210748f44c 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -165,3 +165,9 @@ export function resolveUrl(url: string, to: string) { export function getBasePath(serverUrl: string): string { return new URL(serverUrl).pathname; } + +export function removeQueryString(serverUrl: string): string { + const url = new URL(serverUrl); + url.search = ''; + return url.toString(); +}