fix: only encode non dynamic path params (#8421)

This commit is contained in:
pooya parsa 2020-12-01 16:01:25 +01:00 committed by GitHub
parent 68d8fb8487
commit 49c293b25f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -201,9 +201,10 @@ export const createRoutes = function createRoutes ({
} else if (key === 'index' && i + 1 === keys.length) { } else if (key === 'index' && i + 1 === keys.length) {
route.path += i > 0 ? '' : '/' route.path += i > 0 ? '' : '/'
} else { } 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 += '?' route.path += '?'
} }
} }

View File

@ -47,7 +47,7 @@ import scrollBehavior from './router.scrollBehavior.js'
} }
// @see: https://router.vuejs.org/api/#router-construction-options // @see: https://router.vuejs.org/api/#router-construction-options
res += '{' 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.components) ? nextIndent + 'components: {' + resMap + '\n' + baseIndent + tab + '}' : ''
res += (route.component) ? nextIndent + 'component: ' + route._name : '' res += (route.component) ? nextIndent + 'component: ' + route._name : ''
res += (route.redirect) ? nextIndent + 'redirect: ' + JSON.stringify(route.redirect) : '' res += (route.redirect) ? nextIndent + 'redirect: ' + JSON.stringify(route.redirect) : ''