(path: string, locale?: string)
| 1 | import { parsePath } from '../shared/lib/router/utils/parse-path' |
| 2 | |
| 3 | export function removeLocale(path: string, locale?: string) { |
| 4 | if (process.env.__NEXT_I18N_SUPPORT) { |
| 5 | const { pathname } = parsePath(path) |
| 6 | const pathLower = pathname.toLowerCase() |
| 7 | const localeLower = locale?.toLowerCase() |
| 8 | |
| 9 | return locale && |
| 10 | (pathLower.startsWith(`/${localeLower}/`) || |
| 11 | pathLower === `/${localeLower}`) |
| 12 | ? `${pathname.length === locale.length + 1 ? `/` : ``}${path.slice( |
| 13 | locale.length + 1 |
| 14 | )}` |
| 15 | : path |
| 16 | } |
| 17 | return path |
| 18 | } |
no test coverage detected