export function doesRequestPathMatchLegacyRoute()

in src/msha/routes-engine/route-processor.ts [68:90]


export function doesRequestPathMatchLegacyRoute(
  requestPath: string,
  routeRule: SWAConfigFileRoute | undefined,
  isAuthRequest: boolean,
  isFileRequest: boolean
) {
  const hasWildcard = routeRule?.route.includes("*");

  if (routeRule?.route === requestPath || (!isAuthRequest && hasWildcard)) {
    return true;
  }

  // since this is a file request, don't perform the wildcard matching check
  if (isFileRequest) {
    return false;
  }

  // if the request hasn't already matched the route, and the request is a non-file path,
  // try adding /index.html to the path to see if it then matches. This is especially handy
  // to match a request to the /{customPath}/* route
  const alternateRequestPath = getIndexHtml(requestPath);
  return routeRule?.route === alternateRequestPath || (!isAuthRequest && hasWildcard);
}