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

Function defaultShouldServe

packages/python/src/index.ts:1368–1386  ·  view source on GitHub ↗
({
  entrypoint,
  files,
  requestPath,
})

Source from the content-addressed store, hash-verified

1366};
1367
1368export const defaultShouldServe: ShouldServe = ({
1369 entrypoint,
1370 files,
1371 requestPath,
1372}) => {
1373 requestPath = requestPath.replace(/\/$/, ''); // sanitize trailing '/'
1374 entrypoint = entrypoint.replace(/\\/g, '/'); // windows compatibility
1375
1376 if (entrypoint === requestPath && hasProp(files, entrypoint)) {
1377 return true;
1378 }
1379
1380 const { dir, name } = parse(entrypoint);
1381 if (name === 'index' && dir === requestPath && hasProp(files, entrypoint)) {
1382 return true;
1383 }
1384
1385 return false;
1386};
1387
1388function hasProp(obj: { [path: string]: FileFsRef }, key: string): boolean {
1389 return Object.hasOwnProperty.call(obj, key);

Callers 2

shouldServeFunction · 0.85
shouldServeFunction · 0.85

Calls 3

replaceMethod · 0.80
hasPropFunction · 0.70
parseFunction · 0.50

Tested by

no test coverage detected