Unverified Commit 50c75282 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix resolving href with query and matching as (#29246)

parent 8e52126e
...@@ -833,7 +833,9 @@ export default class Router implements BaseRouter { ...@@ -833,7 +833,9 @@ export default class Router implements BaseRouter {
return false return false
} }
const shouldResolveHref = const shouldResolveHref =
url === as || (options as any)._h || (options as any)._shouldResolveHref (options as any)._h ||
(options as any)._shouldResolveHref ||
pathNoQueryHash(url) === pathNoQueryHash(as)
// for static pages with query params in the URL we delay // for static pages with query params in the URL we delay
// marking the router ready until after the query is updated // marking the router ready until after the query is updated
......
...@@ -26,6 +26,10 @@ const Page = () => { ...@@ -26,6 +26,10 @@ const Page = () => {
<a id="view-post-1-hash-1-href-only">View post 1 (hash only href)</a> <a id="view-post-1-hash-1-href-only">View post 1 (hash only href)</a>
</Link> </Link>
<br /> <br />
<Link href="/post-1?hidden=value" as="/post-1">
<a id="view-post-1-hidden-query">View post 1 (href query)</a>
</Link>
<br />
<Link <Link
href={{ href={{
hash: 'my-hash', hash: 'my-hash',
......
...@@ -368,6 +368,23 @@ function runTests(dev) { ...@@ -368,6 +368,23 @@ function runTests(dev) {
} }
}) })
it('should navigate to a dynamic page with href with differing query and as correctly', async () => {
let browser
try {
browser = await webdriver(appPort, '/')
await browser.eval('window.beforeNav = 1')
await browser.elementByCss('#view-post-1-hidden-query').click()
await browser.waitForElementByCss('#asdf')
expect(await browser.eval('window.beforeNav')).toBe(1)
const text = await browser.elementByCss('#asdf').text()
expect(text).toMatch(/this is.*?post-1/i)
} finally {
if (browser) await browser.close()
}
})
it('should navigate to a dynamic page successfully no as', async () => { it('should navigate to a dynamic page successfully no as', async () => {
let browser let browser
try { try {
......
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