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

Function normalizeEdgeFunctionPath

packages/next/src/utils.ts:3930–3956  ·  view source on GitHub ↗
(
  shortPath: string,
  appPathRoutesManifest: Record<string, string>
)

Source from the content-addressed store, hash-verified

3928}
3929
3930export function normalizeEdgeFunctionPath(
3931 shortPath: string,
3932 appPathRoutesManifest: Record<string, string>
3933) {
3934 if (
3935 shortPath.startsWith('app/') &&
3936 (shortPath.endsWith('/page') ||
3937 shortPath.endsWith('/route') ||
3938 shortPath === 'app/_not-found')
3939 ) {
3940 const ogRoute = shortPath.replace(/^app\//, '/');
3941 shortPath = (
3942 appPathRoutesManifest[ogRoute] ||
3943 shortPath.replace(/(^|\/)(page|route)$/, '')
3944 ).replace(/^\//, '');
3945
3946 if (!shortPath || shortPath === '/') {
3947 shortPath = 'index';
3948 }
3949 }
3950
3951 if (shortPath.startsWith('pages/')) {
3952 shortPath = shortPath.replace(/^pages\//, '');
3953 }
3954
3955 return shortPath;
3956}
3957
3958export async function getNodeMiddleware({
3959 config,

Callers 2

getMiddlewareBundleFunction · 0.85
getServerlessPagesFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected