Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SSG data request failing with trailing slash #10140

Merged
merged 2 commits into from Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/next-server/lib/router/router.ts
Expand Up @@ -666,7 +666,7 @@ export default class Router implements BaseRouter {

_getStaticData = (asPath: string, _cachedData?: object): Promise<object> => {
let pathname = parse(asPath).pathname
pathname = !pathname || pathname === '/' ? '/index' : pathname
pathname = toRoute(!pathname || pathname === '/' ? '/index' : pathname)

return process.env.NODE_ENV === 'production' &&
(_cachedData = this.sdc[pathname])
Expand Down
2 changes: 1 addition & 1 deletion test/integration/prerender/pages/index.js
Expand Up @@ -14,7 +14,7 @@ const Page = ({ world, time }) => {
<>
<p>hello {world}</p>
<span>time: {time}</span>
<Link href="/another">
<Link href="/another?hello=world" as="/another/?hello=world">
<a id="another">to another</a>
</Link>
<br />
Expand Down
2 changes: 2 additions & 0 deletions test/integration/prerender/test/index.test.js
Expand Up @@ -134,9 +134,11 @@ const navigateTest = (dev = false) => {

// go to /another
async function goFromHomeToAnother() {
await browser.eval('window.beforeAnother = true')
await browser.elementByCss('#another').click()
await browser.waitForElementByCss('#home')
text = await browser.elementByCss('p').text()
expect(await browser.eval('window.beforeAnother')).toBe(true)
expect(text).toMatch(/hello.*?world/)
}
await goFromHomeToAnother()
Expand Down