Download next.js/packages/next/src/server/normalizers/locale-route-normalizer.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 620 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/normalizers/locale-route-normalizer.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/server/normalizers/locale-route-normalizer.ts
-
curl -L -o locale-route-normalizer.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/normalizers/locale-route-normalizer.ts
620 Bytes
| import type { I18NProvider } from '../lib/i18n-provider' | |
| import type { Normalizer } from './normalizer' | |
| /** | |
| * Normalizes the pathname by removing the locale prefix if any. | |
| */ | |
| export class LocaleRouteNormalizer implements Normalizer { | |
| constructor(private readonly provider: I18NProvider) {} | |
| /** | |
| * Normalizes the pathname by removing the locale prefix if any. | |
| * | |
| * @param pathname The pathname to normalize. | |
| * @returns The pathname without the locale prefix (if any). | |
| */ | |
| public normalize(pathname: string): string { | |
| const match = this.provider.analyze(pathname) | |
| return match.pathname | |
| } | |
| } | |