Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(route-alis): preserve route previous aliases #91

Merged
merged 3 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ function processRoutes () {
for (const route of routes) {
route.meta = route.meta || {}
route.alias = route.alias || []
if (typeof route.alias === 'string') {
route.alias = [route.alias]
}

if (route.path === '/amp' || route.path.indexOf('/amp/') === 0) {
route.meta.amp = true
} else {
route.alias = '/amp' + route.path
route.alias.push('/amp' + route.path)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion test/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Generates routes', () => {

test('Routes should be correctly localized', () => {
routes.forEach((route) => {
expect(route.alias).toEqual(`/amp${route.path}`)
expect(route.alias).toEqual([`/amp${route.path}`])
})
})
})
Expand Down