silverwolf-x/project / packages /next /src /client /remove-locale.ts
silverwolf-x's picture
download
raw
563 Bytes
import { parsePath } from '../shared/lib/router/utils/parse-path'
export function removeLocale(path: string, locale?: string) {
if (process.env.__NEXT_I18N_SUPPORT) {
const { pathname } = parsePath(path)
const pathLower = pathname.toLowerCase()
const localeLower = locale?.toLowerCase()
return locale &&
(pathLower.startsWith(`/${localeLower}/`) ||
pathLower === `/${localeLower}`)
? `${pathname.length === locale.length + 1 ? `/` : ``}${path.slice(
locale.length + 1
)}`
: path
}
return path
}

Xet Storage Details

Size:
563 Bytes
·
Xet hash:
5b9995a38d0c747707cac3ce3d34ff9e30657c3a65bd9cb3c59bf64b7e22941c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.