From ef30e7ff2d9a2d097288081fdab237f13117590c Mon Sep 17 00:00:00 2001 From: j1gs4w Date: Tue, 3 Dec 2019 14:17:49 +0100 Subject: [PATCH 1/3] fix: add route alias to array instead of overwriting it --- lib/module.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/module.js b/lib/module.js index d5fae603..f986cbb8 100644 --- a/lib/module.js +++ b/lib/module.js @@ -38,11 +38,13 @@ 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) } } }) From 40da3e63063968d71d106f37046900bfb896b818 Mon Sep 17 00:00:00 2001 From: j1gs4w Date: Tue, 3 Dec 2019 14:31:53 +0100 Subject: [PATCH 2/3] fix: eslint errors --- lib/module.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/module.js b/lib/module.js index f986cbb8..e53c070b 100644 --- a/lib/module.js +++ b/lib/module.js @@ -38,8 +38,9 @@ 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 (typeof route.alias === 'string') { + route.alias = [route.alias] + } if (route.path === '/amp' || route.path.indexOf('/amp/') === 0) { route.meta.amp = true From 14ee96529cac18eca4e17283c1b005ce9832d334 Mon Sep 17 00:00:00 2001 From: j1gs4w Date: Tue, 3 Dec 2019 14:40:40 +0100 Subject: [PATCH 3/3] fix: module test because alias is now an array --- test/module.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/module.test.js b/test/module.test.js index ed05e0ab..6d046a47 100644 --- a/test/module.test.js +++ b/test/module.test.js @@ -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}`]) }) }) })