File size: 391 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import { parsePath } from './parse-path'
/**
* Adds the provided prefix to the given path. It first ensures that the path
* is indeed starting with a slash.
*/
export function addPathPrefix(path: string, prefix?: string) {
if (!path.startsWith('/') || !prefix) {
return path
}
const { pathname, query, hash } = parsePath(path)
return `${prefix}${pathname}${query}${hash}`
}
|