next.js/packages/next/src/server/get-app-route-from-entrypoint.ts
get-app-route-from-entrypoint.ts18 lines380 B
import matchBundle from './match-bundle'

// matches app/:path*.js
const APP_ROUTE_NAME_REGEX = /^app[/\\](.*)$/

export default function getAppRouteFromEntrypoint(entryFile: string) {
  const pagePath = matchBundle(APP_ROUTE_NAME_REGEX, entryFile)
  if (typeof pagePath === 'string' && !pagePath) {
    return '/'
  }

  if (!pagePath) {
    return null
  }

  return pagePath
}
Quest for Codev2.0.0
/
SIGN IN