mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
fix(generator): remove trailing slash when no subFolders are used (#6362)
This commit is contained in:
parent
e3e8bf6150
commit
f28d12c913
@ -243,7 +243,8 @@ export default class Generator {
|
||||
fileName = path.join(route, path.sep, 'index.html') // /about -> /about/index.html
|
||||
fileName = fileName === '/404/index.html' ? '/404.html' : fileName // /404 -> /404.html
|
||||
} else {
|
||||
fileName = route.length > 1 ? path.join(path.sep, route + '.html') : path.join(path.sep, 'index.html')
|
||||
const normalizedRoute = route.replace(/\/$/, '')
|
||||
fileName = route.length > 1 ? path.join(path.sep, normalizedRoute + '.html') : path.join(path.sep, 'index.html')
|
||||
}
|
||||
|
||||
// Call hook to let user update the path & html
|
||||
|
@ -36,14 +36,14 @@ describe('generator: generate route', () => {
|
||||
const generator = new Generator(nuxt)
|
||||
path.join.mockClear()
|
||||
|
||||
const route = '/foo'
|
||||
const route = '/foo/'
|
||||
const payload = {}
|
||||
const errors = []
|
||||
|
||||
const returned = await generator.generateRoute({ route, payload, errors })
|
||||
|
||||
expect(nuxt.server.renderRoute).toBeCalledTimes(1)
|
||||
expect(nuxt.server.renderRoute).toBeCalledWith('/foo', { _generate: true, payload })
|
||||
expect(nuxt.server.renderRoute).toBeCalledWith('/foo/', { _generate: true, payload })
|
||||
expect(path.join).toBeCalledTimes(2)
|
||||
expect(path.join).nthCalledWith(1, '[sep]', '/foo.html')
|
||||
expect(path.join).nthCalledWith(2, generator.distPath, 'join([sep], /foo.html)')
|
||||
|
Loading…
Reference in New Issue
Block a user