From 49c293b25f2ec0246ad010bbd71508083ed456bc Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Tue, 1 Dec 2020 16:01:25 +0100 Subject: [PATCH] fix: only encode non dynamic path params (#8421) --- packages/utils/src/route.js | 5 +++-- packages/vue-app/template/router.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/route.js b/packages/utils/src/route.js index c4d106fb5a..40be60903e 100644 --- a/packages/utils/src/route.js +++ b/packages/utils/src/route.js @@ -201,9 +201,10 @@ export const createRoutes = function createRoutes ({ } else if (key === 'index' && i + 1 === keys.length) { route.path += i > 0 ? '' : '/' } else { - route.path += '/' + getRoutePathExtension(key) + const isDynamic = key.startsWith('_') + route.path += '/' + getRoutePathExtension(isDynamic ? key : encodeURIComponent(decodeURIComponent(key))) - if (key.startsWith('_') && key.length > 1) { + if (isDynamic && key.length > 1) { route.path += '?' } } diff --git a/packages/vue-app/template/router.js b/packages/vue-app/template/router.js index c859a0b872..32d8331944 100644 --- a/packages/vue-app/template/router.js +++ b/packages/vue-app/template/router.js @@ -47,7 +47,7 @@ import scrollBehavior from './router.scrollBehavior.js' } // @see: https://router.vuejs.org/api/#router-construction-options res += '{' - res += firstIndent + 'path: ' + JSON.stringify(encodeURI(decodeURI(route.path))) + res += firstIndent + 'path: ' + JSON.stringify(route.path) res += (route.components) ? nextIndent + 'components: {' + resMap + '\n' + baseIndent + tab + '}' : '' res += (route.component) ? nextIndent + 'component: ' + route._name : '' res += (route.redirect) ? nextIndent + 'redirect: ' + JSON.stringify(route.redirect) : ''