mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Fix the page-loader-normalization issue on '/index' page. (#1882)
This commit is contained in:
parent
68880bc9f8
commit
0edee47d07
|
@ -18,9 +18,10 @@ export default class PageLoader {
|
|||
if (route[0] !== '/') {
|
||||
throw new Error('Route name should start with a "/"')
|
||||
}
|
||||
route = route.replace(/index$/, '')
|
||||
|
||||
if (route === '/') return route
|
||||
return route.replace(/index$/, '').replace(/\/$/, '')
|
||||
return route.replace(/\/$/, '')
|
||||
}
|
||||
|
||||
loadPage (route) {
|
||||
|
|
2
test/integration/basic/pages/index.js
Normal file
2
test/integration/basic/pages/index.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
import CDM from '../lib/cdm'
|
||||
export default CDM
|
|
@ -323,7 +323,7 @@ export default (context, render) => {
|
|||
})
|
||||
|
||||
describe('with different types of urls', () => {
|
||||
it('on normal page', async () => {
|
||||
it('should work with normal page', async () => {
|
||||
const browser = await webdriver(context.appPort, '/with-cdm')
|
||||
const text = await browser.elementByCss('p').text()
|
||||
|
||||
|
@ -331,7 +331,7 @@ export default (context, render) => {
|
|||
browser.close()
|
||||
})
|
||||
|
||||
it('on dir/index page ', async () => {
|
||||
it('should work with dir/index page ', async () => {
|
||||
const browser = await webdriver(context.appPort, '/nested-cdm/index')
|
||||
const text = await browser.elementByCss('p').text()
|
||||
|
||||
|
@ -339,13 +339,29 @@ export default (context, render) => {
|
|||
browser.close()
|
||||
})
|
||||
|
||||
it('on dir/ page ', async () => {
|
||||
it('should work with dir/ page ', async () => {
|
||||
const browser = await webdriver(context.appPort, '/nested-cdm/')
|
||||
const text = await browser.elementByCss('p').text()
|
||||
|
||||
expect(text).toBe('ComponentDidMount executed on client.')
|
||||
browser.close()
|
||||
})
|
||||
|
||||
it('should work with /index page', async () => {
|
||||
const browser = await webdriver(context.appPort, '/index')
|
||||
const text = await browser.elementByCss('p').text()
|
||||
|
||||
expect(text).toBe('ComponentDidMount executed on client.')
|
||||
browser.close()
|
||||
})
|
||||
|
||||
it('should work with / page', async () => {
|
||||
const browser = await webdriver(context.appPort, '/')
|
||||
const text = await browser.elementByCss('p').text()
|
||||
|
||||
expect(text).toBe('ComponentDidMount executed on client.')
|
||||
browser.close()
|
||||
})
|
||||
})
|
||||
|
||||
describe('with asPath', () => {
|
||||
|
|
Loading…
Reference in a new issue