bc2cb2210f
Noticed this while reviewing https://github.com/vercel/next.js/pull/14376. After having done https://github.com/vercel/next.js/pull/13699, this code didn't feel right to me: ```js function prepareRoute(path: string) { path = delBasePath(path || '') // this /index rewrite is problematic, it makes pages/index.js // and pages/index/index.js point to the same thing: return toRoute(!path || path === '/' ? '/index' : path) } ``` Added a nested index page to the prerender tests and found it was rendering the `/` route on navigation. This uncovered 2 more places around the dataroute where the index path was not translated correctly. **edit:** Just to note that there was nothing wrong with https://github.com/vercel/next.js/pull/14376, the issue was already there, I just noticed it while reading that PR
22 lines
457 B
JavaScript
22 lines
457 B
JavaScript
import { useRouter } from 'next/router'
|
|
|
|
export const getStaticProps = () => {
|
|
return {
|
|
props: {
|
|
nested: false,
|
|
hello: 'hello',
|
|
},
|
|
}
|
|
}
|
|
|
|
export default function Index({ hello, nested }) {
|
|
const { query, pathname } = useRouter()
|
|
return (
|
|
<>
|
|
<p id="nested">{nested ? 'yes' : 'no'}</p>
|
|
<p id="prop">{hello} world</p>
|
|
<p id="query">{JSON.stringify(query)}</p>
|
|
<p id="pathname">{pathname}</p>
|
|
</>
|
|
)
|
|
}
|