未验证 提交 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 ({ ...@@ -93,7 +93,7 @@ export default async function ({
} }
const baseDir = join(outDir, dirname(htmlFilename)) const baseDir = join(outDir, dirname(htmlFilename))
const htmlFilepath = join(outDir, htmlFilename) let htmlFilepath = join(outDir, htmlFilename)
await mkdirp(baseDir) await mkdirp(baseDir)
let html let html
...@@ -117,6 +117,12 @@ export default async function ({ ...@@ -117,6 +117,12 @@ export default async function ({
// prerendered the file // prerendered the file
if (renderedDuringBuild(mod.unstable_getStaticProps)) return results 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 renderMethod = mod.renderReqToHTML
const result = await renderMethod(req, res, true) const result = await renderMethod(req, res, true)
curRenderOpts = result.renderOpts || {} curRenderOpts = result.renderOpts || {}
...@@ -139,6 +145,16 @@ export default async function ({ ...@@ -139,6 +145,16 @@ export default async function ({
return results 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') { if (typeof components.Component === 'string') {
html = components.Component html = components.Component
} else { } else {
......
...@@ -3,7 +3,12 @@ import Link from 'next/link' ...@@ -3,7 +3,12 @@ import Link from 'next/link'
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
export async function unstable_getStaticParams () { 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 // eslint-disable-next-line camelcase
......
...@@ -75,6 +75,11 @@ const expectedManifestRoutes = () => ({ ...@@ -75,6 +75,11 @@ const expectedManifestRoutes = () => ({
initialRevalidateSeconds: 2, initialRevalidateSeconds: 2,
srcRoute: '/blog/[post]/[comment]' srcRoute: '/blog/[post]/[comment]'
}, },
'/blog/post.1': {
dataRoute: `/_next/data/${buildId}/blog/post.1.json`,
initialRevalidateSeconds: 10,
srcRoute: '/blog/[post]'
},
'/another': { '/another': {
dataRoute: `/_next/data/${buildId}/another.json`, dataRoute: `/_next/data/${buildId}/another.json`,
initialRevalidateSeconds: 0, initialRevalidateSeconds: 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册