Download next.js/packages/next/src/shared/lib/router/utils/is-dynamic.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 822 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/is-dynamic.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/router/utils/is-dynamic.ts
-
curl -L -o is-dynamic.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/is-dynamic.ts
822 Bytes
| import { | |
| extractInterceptionRouteInformation, | |
| isInterceptionRouteAppPath, | |
| } from './interception-routes' | |
| // Identify /.*[param].*/ in route string | |
| const TEST_ROUTE = /\/[^/]*\[[^/]+\][^/]*(?=\/|$)/ | |
| // Identify /[param]/ in route string | |
| const TEST_STRICT_ROUTE = /\/\[[^/]+\](?=\/|$)/ | |
| /** | |
| * Check if a route is dynamic. | |
| * | |
| * @param route - The route to check. | |
| * @param strict - Whether to use strict mode which prohibits segments with prefixes/suffixes (default: true). | |
| * @returns Whether the route is dynamic. | |
| */ | |
| export function isDynamicRoute(route: string, strict: boolean = true): boolean { | |
| if (isInterceptionRouteAppPath(route)) { | |
| route = extractInterceptionRouteInformation(route).interceptedRoute | |
| } | |
| if (strict) { | |
| return TEST_STRICT_ROUTE.test(route) | |
| } | |
| return TEST_ROUTE.test(route) | |
| } | |