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

Function findBuildMatch

packages/cli/src/util/dev/server.ts:3232–3270  ·  view source on GitHub ↗
(
  matches: Map<string, BuildMatch>,
  files: BuilderInputs,
  requestPath: string,
  devServer: DevServer,
  vercelConfig: VercelConfig,
  isFilesystem = false
)

Source from the content-addressed store, hash-verified

3230}
3231
3232async function findBuildMatch(
3233 matches: Map<string, BuildMatch>,
3234 files: BuilderInputs,
3235 requestPath: string,
3236 devServer: DevServer,
3237 vercelConfig: VercelConfig,
3238 isFilesystem = false
3239): Promise<BuildMatch | null> {
3240 requestPath = requestPath.replace(/^\//, '');
3241
3242 let bestIndexMatch: undefined | BuildMatch;
3243 for (const match of matches.values()) {
3244 if (
3245 await shouldServe(
3246 match,
3247 files,
3248 requestPath,
3249 devServer,
3250 vercelConfig,
3251 isFilesystem,
3252 !!bestIndexMatch
3253 )
3254 ) {
3255 if (!isIndex(match.src)) {
3256 return match;
3257 } else {
3258 // If isIndex === true and ends in `.html`, we're done.
3259 // Otherwise, keep searching.
3260 if (extname(match.src) === '.html') {
3261 return match;
3262 }
3263 bestIndexMatch = match;
3264 }
3265 }
3266 }
3267
3268 // return a non-.html index file or none are found
3269 return bestIndexMatch || null;
3270}
3271
3272async function shouldServe(
3273 match: BuildMatch,

Callers 2

DevServerClass · 0.85
hasFilesystemMethod · 0.85

Calls 4

isIndexFunction · 0.85
replaceMethod · 0.80
shouldServeFunction · 0.70
valuesMethod · 0.45

Tested by

no test coverage detected