mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +00:00
vmui: fix trailing slash in serverURL (#5271)
* vmui: add function to autoremove slash at the end of serverURL (#5203) * vmui: change removeTrailingSlash func
This commit is contained in:
parent
12aefa8a4b
commit
0e056ddb2d
2 changed files with 6 additions and 3 deletions
|
@ -3,6 +3,7 @@ import { getQueryStringValue } from "../../utils/query-string";
|
|||
import { getFromStorage, saveToStorage } from "../../utils/storage";
|
||||
import { Theme } from "../../types";
|
||||
import { isDarkTheme } from "../../utils/theme";
|
||||
import { removeTrailingSlash } from "../../utils/url";
|
||||
|
||||
export interface AppState {
|
||||
serverUrl: string;
|
||||
|
@ -20,7 +21,7 @@ export type Action =
|
|||
const tenantId = getQueryStringValue("g0.tenantID", "") as string;
|
||||
|
||||
export const initialState: AppState = {
|
||||
serverUrl: getDefaultServer(tenantId),
|
||||
serverUrl: removeTrailingSlash(getDefaultServer(tenantId)),
|
||||
tenantId,
|
||||
theme: (getFromStorage("THEME") || Theme.system) as Theme,
|
||||
isDarkTheme: null
|
||||
|
@ -31,7 +32,7 @@ export function reducer(state: AppState, action: Action): AppState {
|
|||
case "SET_SERVER":
|
||||
return {
|
||||
...state,
|
||||
serverUrl: action.payload
|
||||
serverUrl: removeTrailingSlash(action.payload)
|
||||
};
|
||||
case "SET_TENANT_ID":
|
||||
return {
|
||||
|
|
|
@ -9,3 +9,5 @@ export const isValidHttpUrl = (str: string): boolean => {
|
|||
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
};
|
||||
|
||||
export const removeTrailingSlash = (url: string) => url.replace(/\/$/, "");
|
||||
|
|
Loading…
Reference in a new issue