Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

to-runtime-path.ts

17 lines687 Bytes

1/**
2 * Converts the given input string to a valid runtime path based on the environment configuration.
3 * If the environment variable `VITE_APP_HISTORY` is set to 'hash', the input will be prefixed with `/#`.
4 * Otherwise, the input will be returned as is.
5 *
6 * @param {string} input - The input string to be converted.
7 * @returns {string} - The converted test URL value.
8 * @example
9 * toRuntimePath('/normal-page') // '/normal-page'
10 * // or
11 * process.env.VITE_APP_HISTORY = 'hash'
12 * toRuntimePath('/normal-page') // '/#/normal-page'
13 */
14export function toRuntimePath(input: string) {
15 const value = process.env.VITE_APP_HISTORY === 'hash' ? `/#${input}` : input
16 return value