Commit 51420c72 authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Fix SSG data request failing with trailing slash (#10140)

* Fix SSG data request failing with trailing slash

* Update to re-use toRoute method
parent ee076125
...@@ -666,7 +666,7 @@ export default class Router implements BaseRouter { ...@@ -666,7 +666,7 @@ export default class Router implements BaseRouter {
_getStaticData = (asPath: string, _cachedData?: object): Promise<object> => { _getStaticData = (asPath: string, _cachedData?: object): Promise<object> => {
let pathname = parse(asPath).pathname let pathname = parse(asPath).pathname
pathname = !pathname || pathname === '/' ? '/index' : pathname pathname = toRoute(!pathname || pathname === '/' ? '/index' : pathname)
return process.env.NODE_ENV === 'production' && return process.env.NODE_ENV === 'production' &&
(_cachedData = this.sdc[pathname]) (_cachedData = this.sdc[pathname])
......
...@@ -14,7 +14,7 @@ const Page = ({ world, time }) => { ...@@ -14,7 +14,7 @@ const Page = ({ world, time }) => {
<> <>
<p>hello {world}</p> <p>hello {world}</p>
<span>time: {time}</span> <span>time: {time}</span>
<Link href="/another"> <Link href="/another?hello=world" as="/another/?hello=world">
<a id="another">to another</a> <a id="another">to another</a>
</Link> </Link>
<br /> <br />
......
...@@ -134,9 +134,11 @@ const navigateTest = (dev = false) => { ...@@ -134,9 +134,11 @@ const navigateTest = (dev = false) => {
// go to /another // go to /another
async function goFromHomeToAnother() { async function goFromHomeToAnother() {
await browser.eval('window.beforeAnother = true')
await browser.elementByCss('#another').click() await browser.elementByCss('#another').click()
await browser.waitForElementByCss('#home') await browser.waitForElementByCss('#home')
text = await browser.elementByCss('p').text() text = await browser.elementByCss('p').text()
expect(await browser.eval('window.beforeAnother')).toBe(true)
expect(text).toMatch(/hello.*?world/) expect(text).toMatch(/hello.*?world/)
} }
await goFromHomeToAnother() await goFromHomeToAnother()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment