提交 b00501e6 编写于 作者: J JJ Kasper 提交者: Tim Neutkens

Add test for /dashboard/index (#7065)

This adds a test to the custom-server suite to make sure we don't regress on this
上级 a7e89eea
......@@ -9,7 +9,11 @@ export type BuildManifest = {
export function getPageFiles(buildManifest: BuildManifest, page: string): string[] {
const normalizedPage = normalizePagePath(page)
const files = buildManifest.pages[normalizedPage]
let files = buildManifest.pages[normalizedPage]
if (!files) {
files = buildManifest.pages[normalizedPage.replace(/\/index$/, '') || '/']
}
if (!files) {
// tslint:disable-next-line
......
......@@ -22,9 +22,13 @@ export function getPagePath(page: string, distDir: string): string {
}
if (!pagesManifest[page]) {
throw pageNotFoundError(page)
const cleanedPage = page.replace(/\/index$/, '') || '/'
if (!pagesManifest[cleanedPage]) {
throw pageNotFoundError(page)
} else {
page = cleanedPage
}
}
return join(serverBuildPath, pagesManifest[page])
}
......
export default () => <p>made it to dashboard</p>
......@@ -28,6 +28,10 @@ app.prepare().then(() => {
return app.render(req, res, '/index')
}
if (/dashboard/.test(req.url)) {
return app.render(req, res, '/dashboard/index')
}
handleNextRequests(req, res)
})
......
......@@ -68,6 +68,11 @@ describe('Custom Server', () => {
expect(dynamicUsage).toMatch(/127\.0\.0\.1/)
}
})
it('should render nested index', async () => {
const html = await renderViaHTTP(appPort, '/dashboard')
expect(html).toMatch(/made it to dashboard/)
})
})
describe('with generateEtags enabled', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册