10d814d31a
Fixes incorrect generated manifest and generated directory for `index/[...dynamic]` pages Too much normalizing adding extra `index/` prefix to `index/[...dynamic]` routes which lead to the incorrected generated routes like `.next/server/pages/index/index/index/[...dynamic]` ## Bug Fixes https://github.com/vercel/customer-issues/issues/146 - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md`
19 lines
643 B
TypeScript
19 lines
643 B
TypeScript
// Translate a pages asset path (relative from a common prefix) back into its logical route
|
|
|
|
import { isDynamicRoute } from './is-dynamic'
|
|
|
|
// "asset path" being its javascript file, data file, prerendered html,...
|
|
export default function getRouteFromAssetPath(
|
|
assetPath: string,
|
|
ext: string = ''
|
|
): string {
|
|
assetPath = assetPath.replace(/\\/g, '/')
|
|
assetPath =
|
|
ext && assetPath.endsWith(ext) ? assetPath.slice(0, -ext.length) : assetPath
|
|
if (assetPath.startsWith('/index/') && !isDynamicRoute(assetPath)) {
|
|
assetPath = assetPath.slice(6)
|
|
} else if (assetPath === '/index') {
|
|
assetPath = '/'
|
|
}
|
|
return assetPath
|
|
}
|