Commit 0edee47d authored by Arunoda Susiripala's avatar Arunoda Susiripala Committed by Guillermo Rauch

Fix the page-loader-normalization issue on '/index' page. (#1882)

parent 68880bc9
...@@ -18,9 +18,10 @@ export default class PageLoader { ...@@ -18,9 +18,10 @@ export default class PageLoader {
if (route[0] !== '/') { if (route[0] !== '/') {
throw new Error('Route name should start with a "/"') throw new Error('Route name should start with a "/"')
} }
route = route.replace(/index$/, '')
if (route === '/') return route if (route === '/') return route
return route.replace(/index$/, '').replace(/\/$/, '') return route.replace(/\/$/, '')
} }
loadPage (route) { loadPage (route) {
......
import CDM from '../lib/cdm'
export default CDM
...@@ -323,7 +323,7 @@ export default (context, render) => { ...@@ -323,7 +323,7 @@ export default (context, render) => {
}) })
describe('with different types of urls', () => { 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 browser = await webdriver(context.appPort, '/with-cdm')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
...@@ -331,7 +331,7 @@ export default (context, render) => { ...@@ -331,7 +331,7 @@ export default (context, render) => {
browser.close() 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 browser = await webdriver(context.appPort, '/nested-cdm/index')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
...@@ -339,13 +339,29 @@ export default (context, render) => { ...@@ -339,13 +339,29 @@ export default (context, render) => {
browser.close() browser.close()
}) })
it('on dir/ page ', async () => { it('should work with dir/ page ', async () => {
const browser = await webdriver(context.appPort, '/nested-cdm/') const browser = await webdriver(context.appPort, '/nested-cdm/')
const text = await browser.elementByCss('p').text() const text = await browser.elementByCss('p').text()
expect(text).toBe('ComponentDidMount executed on client.') expect(text).toBe('ComponentDidMount executed on client.')
browser.close() 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', () => { describe('with asPath', () => {
......
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