From 91f3c80e297df90a1b0d357fc7e432fa7b977691 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 6 Dec 2019 20:16:56 +0100 Subject: [PATCH] fix(route-alis): preserve route previous aliases (#91) * fix: add route alias to array instead of overwriting it * fix: eslint errors * fix: module test because alias is now an array --- lib/module.js | 5 ++++- test/module.test.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/module.js b/lib/module.js index d5fae603..e53c070b 100644 --- a/lib/module.js +++ b/lib/module.js @@ -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) } } }) 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}`]) }) }) })