Download next.js/packages/next/src/shared/lib/page-path/normalize-data-path.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 428 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/page-path/normalize-data-path.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/page-path/normalize-data-path.ts
-
curl -L -o normalize-data-path.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/page-path/normalize-data-path.ts
428 Bytes
| import { pathHasPrefix } from '../router/utils/path-has-prefix' | |
| /** | |
| * strip _next/data/<build-id>/ prefix and .json suffix | |
| */ | |
| export function normalizeDataPath(pathname: string) { | |
| if (!pathHasPrefix(pathname || '/', '/_next/data')) { | |
| return pathname | |
| } | |
| pathname = pathname | |
| .replace(/\/_next\/data\/[^/]{1,}/, '') | |
| .replace(/\.json$/, '') | |
| if (pathname === '/index') { | |
| return '/' | |
| } | |
| return pathname | |
| } | |