mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Rewrite url when exporting only if there's a href. (#2316)
This commit is contained in:
parent
7b8a4ea234
commit
8277d43190
|
@ -129,6 +129,7 @@ export default class Link extends Component {
|
|||
// Add the ending slash to the paths. So, we can serve the
|
||||
// "<page>/index.html" directly.
|
||||
if (
|
||||
props.href &&
|
||||
typeof __NEXT_DATA__ !== 'undefined' &&
|
||||
__NEXT_DATA__.nextExport
|
||||
) {
|
||||
|
|
|
@ -3,6 +3,7 @@ module.exports = {
|
|||
return {
|
||||
'/': { page: '/' },
|
||||
'/about': { page: '/about' },
|
||||
'/button-link': { page: '/button-link' },
|
||||
'/get-initial-props-with-no-query': { page: '/get-initial-props-with-no-query' },
|
||||
'/counter': { page: '/counter' },
|
||||
'/dynamic-imports': { page: '/dynamic-imports' },
|
||||
|
|
12
test/integration/static/pages/button-link.js
Normal file
12
test/integration/static/pages/button-link.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
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) {
|
|||
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', () => {
|
||||
it('should render the home page', async () => {
|
||||
const browser = await webdriver(context.port, '/')
|
||||
|
|
|
@ -5319,7 +5319,11 @@ utils-merge@1.0.0:
|
|||
version "1.0.0"
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"
|
||||
|
||||
|
|
Loading…
Reference in a new issue