From 10c1d9dc4fad587de64fbec27254692b7cf73154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Wed, 25 Sep 2019 23:10:46 +0200 Subject: [PATCH] fix: Locale prefixes missing for child routes with custom paths If one assigned (in component options or pages object) custom, absolute paths for routes and those routes were child routes, then those routes didn't get the locale prefix assigned as prefix was never added to child routes. That wasn't a problem if route was a top-level route or no custom paths were assigned as then the path was relative and didn't need locale prefix to be added. Fix by also adding locale prefix for routes that are child routes with absolute path. Resolves #359 --- src/helpers/routes.js | 6 ++++-- test/fixture/basic/pages/posts/index.vue | 22 +++++++++++----------- test/module.test.js | 9 +++++++++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/helpers/routes.js b/src/helpers/routes.js index 0715b0f57..90e3cb146 100644 --- a/src/helpers/routes.js +++ b/src/helpers/routes.js @@ -116,12 +116,14 @@ exports.makeRoutes = (baseRoutes, { } } + const isChildWithRelativePath = isChild && !path.startsWith('/') + // Add route prefix if needed const shouldAddPrefix = ( // No prefix if app uses different locale domains !differentDomains && - // Only add prefix on top level routes - !isChild && + // No need to add prefix if child's path is relative + !isChildWithRelativePath && // Skip default locale if strategy is PREFIX_EXCEPT_DEFAULT !(locale === defaultLocale && strategy === STRATEGIES.PREFIX_EXCEPT_DEFAULT) ) diff --git a/test/fixture/basic/pages/posts/index.vue b/test/fixture/basic/pages/posts/index.vue index 04b161fae..7b55e555d 100644 --- a/test/fixture/basic/pages/posts/index.vue +++ b/test/fixture/basic/pages/posts/index.vue @@ -1,19 +1,19 @@