Commit 8277d431 authored by Arunoda Susiripala's avatar Arunoda Susiripala Committed by GitHub

Rewrite url when exporting only if there's a href. (#2316)

parent 7b8a4ea2
...@@ -129,6 +129,7 @@ export default class Link extends Component { ...@@ -129,6 +129,7 @@ export default class Link extends Component {
// Add the ending slash to the paths. So, we can serve the // Add the ending slash to the paths. So, we can serve the
// "<page>/index.html" directly. // "<page>/index.html" directly.
if ( if (
props.href &&
typeof __NEXT_DATA__ !== 'undefined' && typeof __NEXT_DATA__ !== 'undefined' &&
__NEXT_DATA__.nextExport __NEXT_DATA__.nextExport
) { ) {
......
...@@ -3,6 +3,7 @@ module.exports = { ...@@ -3,6 +3,7 @@ module.exports = {
return { return {
'/': { page: '/' }, '/': { page: '/' },
'/about': { page: '/about' }, '/about': { page: '/about' },
'/button-link': { page: '/button-link' },
'/get-initial-props-with-no-query': { page: '/get-initial-props-with-no-query' }, '/get-initial-props-with-no-query': { page: '/get-initial-props-with-no-query' },
'/counter': { page: '/counter' }, '/counter': { page: '/counter' },
'/dynamic-imports': { page: '/dynamic-imports' }, '/dynamic-imports': { page: '/dynamic-imports' },
......
import Link from 'next/link'
export default () => (
<div id='button-link-page'>
<div>
<Link href='/'>
<button>Go Back</button>
</Link>
</div>
<p>This is the About page</p>
</div>
)
...@@ -135,6 +135,18 @@ export default function (context) { ...@@ -135,6 +135,18 @@ export default function (context) {
browser.close() browser.close()
}) })
it('should navigate even if used a button inside <Link />', async () => {
const browser = await webdriver(context.port, '/button-link')
const text = await browser
.elementByCss('button').click()
.waitForElementByCss('#home-page')
.elementByCss('#home-page p').text()
expect(text).toBe('This is the home page')
browser.close()
})
describe('pages in the nested level: level1', () => { describe('pages in the nested level: level1', () => {
it('should render the home page', async () => { it('should render the home page', async () => {
const browser = await webdriver(context.port, '/') const browser = await webdriver(context.port, '/')
......
...@@ -5319,7 +5319,11 @@ utils-merge@1.0.0: ...@@ -5319,7 +5319,11 @@ utils-merge@1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8"
uuid@3.0.1, uuid@^3.0.0: uuid@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"
uuid@^3.0.0:
version "3.0.1" version "3.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"
......
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