Download next.js/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 287 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts
-
curl -L -o remove-trailing-slash.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts
287 Bytes
| /** | |
| * Removes the trailing slash for a given route or page path. Preserves the | |
| * root page. Examples: | |
| * - `/foo/bar/` -> `/foo/bar` | |
| * - `/foo/bar` -> `/foo/bar` | |
| * - `/` -> `/` | |
| */ | |
| export function removeTrailingSlash(route: string) { | |
| return route.replace(/\/$/, '') || '/' | |
| } | |