Files
JJ KasperandGitHub 1203b9082b Ensure path encoding is handled consistently for prerendered pages (#19135)
This ensures we handle encoding/decoding for SSG prerendered/fallback pages correctly. Since we only encode path delimiters when outputting to the disk we need to match this encoding when building the `ssgCacheKey` to look-up the prerendered pages. This also fixes non-ascii prerendered paths (e.g. 商業日語) not matching correctly. 

This does not resolve 👉  https://github.com/vercel/next.js/issues/10084 and further investigation will be needed before addressing non-ascii paths for non-SSG pages. 

The encoding output was tested against https://tst-encoding-l7amu5b9c.vercel.app/ to ensure the values will match correctly on Vercel. 

Closes: https://github.com/vercel/next.js/issues/17582
Closes: https://github.com/vercel/next.js/issues/17642
x-ref: https://github.com/vercel/next.js/pull/14717
2020-12-28 20:08:58 +00:00

40 lines
706 B
JavaScript

import getPaths from '../../paths'
import { useRouter } from 'next/router'
export default function Page(props) {
const router = useRouter()
if (router.isFallback) {
return 'Loading...'
}
return (
<>
<p id="props">{JSON.stringify(props)}</p>
<p id="router">
{JSON.stringify({
query: router.query,
asPath: router.asPath,
pathname: router.pathname,
})}
</p>
</>
)
}
export const getStaticProps = ({ params }) => {
return {
props: {
random: Math.random(),
params,
},
}
}
export const getStaticPaths = () => {
return {
paths: getPaths('/fallback-blocking'),
fallback: 'blocking',
}
}