Skip to content

Commit

Permalink
fix: only encode non dynamic path params (#8421)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Dec 1, 2020
1 parent 68d8fb8 commit 49c293b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/utils/src/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += '?'
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-app/template/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) : ''
Expand Down

0 comments on commit 49c293b

Please sign in to comment.