未验证 提交 f16f868e 编写于 作者: J JJ Kasper 提交者: GitHub

Make sure to handle paths with dot in name for SPR (#9227)

上级 8dd394a0
......@@ -93,7 +93,7 @@ export default async function ({
}
const baseDir = join(outDir, dirname(htmlFilename))
const htmlFilepath = join(outDir, htmlFilename)
let htmlFilepath = join(outDir, htmlFilename)
await mkdirp(baseDir)
let html
......@@ -117,6 +117,12 @@ export default async function ({
// prerendered the file
if (renderedDuringBuild(mod.unstable_getStaticProps)) return results
if (mod.unstable_getStaticProps && !htmlFilepath.endsWith('.html')) {
// make sure it ends with .html if the name contains a dot
htmlFilename += '.html'
htmlFilepath += '.html'
}
renderMethod = mod.renderReqToHTML
const result = await renderMethod(req, res, true)
curRenderOpts = result.renderOpts || {}
......@@ -139,6 +145,16 @@ export default async function ({
return results
}
// TODO: de-dupe the logic here between serverless and server mode
if (
components.unstable_getStaticProps &&
!htmlFilepath.endsWith('.html')
) {
// make sure it ends with .html if the name contains a dot
htmlFilepath += '.html'
htmlFilename += '.html'
}
if (typeof components.Component === 'string') {
html = components.Component
} else {
......
......@@ -3,7 +3,12 @@ import Link from 'next/link'
// eslint-disable-next-line camelcase
export async function unstable_getStaticParams () {
return ['/blog/post-1', { post: 'post-2' }, '/blog/[post3]']
return [
'/blog/post-1',
{ post: 'post-2' },
'/blog/[post3]',
'/blog/post.1'
]
}
// eslint-disable-next-line camelcase
......
......@@ -75,6 +75,11 @@ const expectedManifestRoutes = () => ({
initialRevalidateSeconds: 2,
srcRoute: '/blog/[post]/[comment]'
},
'/blog/post.1': {
dataRoute: `/_next/data/${buildId}/blog/post.1.json`,
initialRevalidateSeconds: 10,
srcRoute: '/blog/[post]'
},
'/another': {
dataRoute: `/_next/data/${buildId}/another.json`,
initialRevalidateSeconds: 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册