react-code-dataset / next.js /packages /next /src /server /route-modules /app-route /helpers /get-pathname-from-absolute-path.ts
Download next.js/packages/next/src/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 521 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.ts
-
curl -L -o get-pathname-from-absolute-path.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.ts
521 Bytes
| /** | |
| * Get pathname from absolute path. | |
| * | |
| * @param absolutePath the absolute path | |
| * @returns the pathname | |
| */ | |
| export function getPathnameFromAbsolutePath(absolutePath: string) { | |
| // Remove prefix including app dir | |
| let appDir = '/app/' | |
| if (!absolutePath.includes(appDir)) { | |
| appDir = '\\app\\' | |
| } | |
| const [, ...parts] = absolutePath.split(appDir) | |
| const relativePath = appDir[0] + parts.join(appDir) | |
| // remove extension | |
| const pathname = relativePath.split('.').slice(0, -1).join('.') | |
| return pathname | |
| } | |