rsnext/packages/next/server/get-app-route-from-entrypoint.ts
Wyatt Johnson f5cab2f515
App Build Stats (#38884)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-10 19:31:01 +00:00

17 lines
380 B
TypeScript

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
}