MCPcopy Create free account
hub / github.com/vercel/vercel / normalizeDataRoute

Function normalizeDataRoute

packages/next/src/utils.ts:2936–2956  ·  view source on GitHub ↗
(route: string)

Source from the content-addressed store, hash-verified

2934 let lambda: undefined | Lambda;
2935
2936 function normalizeDataRoute(route: string) {
2937 let normalized = path.posix.join(entryDirectory, route);
2938
2939 if (nonDynamicSsg || isFallback || isOmitted) {
2940 // the prerender-manifest can be inconsistent with
2941 // locale being provided to dataRoute so normalize here
2942 const pathToReplace = route.endsWith(routeFileNoExt + '.json')
2943 ? origRouteFileNoExt
2944 : routeFileNoExt;
2945
2946 normalized = normalized.replace(
2947 new RegExp(`${escapeStringRegexp(origRouteFileNoExt)}.json$`),
2948 // ensure we escape "$" correctly while replacing as "$" is a special
2949 // character, we need to do double escaping as first is for the initial
2950 // replace on the routeFile and then the second on the outputPath
2951 `${pathToReplace.replace(/\$/g, '$$$$')}.json`
2952 );
2953 }
2954
2955 return normalized;
2956 }
2957
2958 let outputPathData: null | string = null;
2959 if (dataRoute) {

Callers 1

onPrerenderRouteFunction · 0.85

Calls 2

replaceMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected