daab64c27e
* Extract `detect-domain-locale` to a util file * Remove `pathNoQueryHash` in favor of `parsePath` * Remove `hasPathPrefix` in favor of `pathHasPrefix` * Remove `addPathPrefix` in favor of an existing util * Bugfix parsing pathname * Refactor `addLocale` * Extract `removeLocale` * Extract `basePath` utils * Dynamic imports for `getDomainLocale`
14 lines
462 B
TypeScript
14 lines
462 B
TypeScript
import { addPathPrefix } from '../shared/lib/router/utils/add-path-prefix'
|
|
import { normalizePathTrailingSlash } from './normalize-trailing-slash'
|
|
|
|
const basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''
|
|
|
|
export function addBasePath(path: string, required?: boolean): string {
|
|
if (process.env.__NEXT_MANUAL_CLIENT_BASE_PATH) {
|
|
if (!required) {
|
|
return path
|
|
}
|
|
}
|
|
|
|
return normalizePathTrailingSlash(addPathPrefix(path, basePath))
|
|
}
|