rsnext/test/integration/dynamic-optional-routing/pages/get-static-paths-undefined/[[...slug]].js
Jan Potoms 8bac412845
make getStaticPaths work with optional catch-all routes (#13559)
Fixes https://github.com/vercel/next.js/issues/13524

To do:
- [x] fix dev mode
- [x] there's a ~route ordering or~ trailing slash issue with top level catch-all (current tests reflect that)
- [x] in this test `/get-static-paths/whatever` should fall back to `/[[...optionalName]].js` since `fallback` is `false` in its `getStaticPaths` method. ~Currently seems to 500~ must have been a glitch
- [x] add tests for `null`, `undefined` ~and `false`~ behavior as well (if decided these are valid)
- [x] ~add tests for string params as well~ this is not allowed for catch-all routes
- [x] test behavior when fallback is enabled and a top level catch-all exists
2020-06-01 17:08:34 +00:00

25 lines
466 B
JavaScript

export async function getStaticPaths() {
return {
paths: [
{
params: { slug: undefined },
},
],
fallback: false,
}
}
export async function getStaticProps({ params }) {
return { props: { params } }
}
export default function Index(props) {
return (
<div id="route">
gsp undefined route:{' '}
{props.params.slug === undefined
? 'undefined'
: `[${props.params.slug.join('|')}]`}
</div>
)
}