aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/frontend/src/main/components/utils/requests.tsx
blob: 568c331bca5dcc093aaadec7253125abd0fbc1b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

import {IWindow} from "../search/types"

export const relativizeUrlForRequest = (filePath: string) : string => {
    const pathToRoot = (window as IWindow).pathToRoot
    const relativePath = pathToRoot == "" ? "." : pathToRoot
    return relativePath.endsWith('/') ? `${relativePath}${filePath}` : `${relativePath}/${filePath}`
}