8000 decode URI when aborting transition (Fix #760) (#1020) · vuejs/vue-router@efadecc · GitHub
[go: up one dir, main page]

Skip to content

Commit efadecc

Browse files
LinusBorgyyx990803
authored andcommitted
decode URI when aborting transition (Fix #760) (#1020)
* init commit * add comment explaining the change.
1 parent 03c9cbd commit efadecc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/route-recognizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function warn (msg) {
1414
}
1515
}
1616

17-
function tryDecode (uri, asComponent) {
17+
export function tryDecode (uri, asComponent) {
1818
try {
1919
return asComponent
2020
? decodeURIComponent(uri)

src/transition.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
canReuse
1414
} from './pipeline'
1515

16+
import { tryDecode } from '../lib/route-recognizer'
1617
/**
1718
* A RouteTransition object manages the pipeline of a
1819
* router-view switching process. This is also the object
@@ -45,7 +46,10 @@ export default class RouteTransition {
4546
// on initial load, it gets caught in an infinite loop.
4647
const abortingOnLoad = !this.from.path && this.to.path === '/'
4748
if (!abortingOnLoad) {
48-
this.router.replace(this.from.path || '/')
49+
// When aborting, we have to decode the Path, because router.replace()
50+
// will encode it again. (https://github.com/vuejs/vue-router/issues/760)
51+
const path = this.from.path ? tryDecode(this.from.path, true) : '/'
52+
this.router.replace(path)
4953
}
5054
}
5155
}

0 commit comments

Comments
 (0)
0