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

* Fix SSG data request failing with trailing slash

* Update to re-use toRoute method
This commit is contained in:
JJ Kasper 2020-01-17 10:54:00 -06:00 committed by Joe Haddad
parent ee0761255a
commit 51420c7241
3 changed files with 4 additions and 2 deletions

View file

@ -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])

View file

@ -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 />

View file

@ -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()