|
1 | 1 | /*!
|
2 |
| - * vue-router v3.0.3 |
| 2 | + * vue-router v3.0.4 |
3 | 3 | * (c) 2019 Evan You
|
4 | 4 | * @license MIT
|
5 | 5 | */
|
@@ -2337,7 +2337,23 @@ function getHash () {
|
2337 | 2337 | // consistent across browsers - Firefox will pre-decode it!
|
2338 | 2338 | var href = window.location.href;
|
2339 | 2339 | var index = href.indexOf('#');
|
2340 |
| - return index === -1 ? '' : decodeURI(href.slice(index + 1)) |
| 2340 | + // empty path |
| 2341 | + if (index < 0) { return '' } |
| 2342 | + |
| 2343 | + href = href.slice(index + 1); |
| 2344 | + // decode the hash but not the search or hash |
| 2345 | + // as search(query) is already decoded |
| 2346 | + // https://github.com/vuejs/vue-router/issues/2708 |
| 2347 | + var searchIndex = href.indexOf('?'); |
| 2348 | + if (searchIndex < 0) { |
| 2349 | + var hashIndex = href.indexOf('#'); |
| 2350 | + if (hashIndex > -1) { href = decodeURI(href.slice(0, hashIndex)) + href.slice(hashIndex); } |
| 2351 | + else { href = decodeURI(href); } |
| 2352 | + } else { |
| 2353 | + if (searchIndex > -1) { href = decodeURI(href.slice(0, searchIndex)) + href.slice(searchIndex); } |
| 2354 | + } |
| 2355 | + |
| 2356 | + return href |
2341 | 2357 | }
|
2342 | 2358 |
|
2343 | 2359 | function getUrl (path) {
|
@@ -2488,7 +2504,19 @@ VueRouter.prototype.init = function init (app /* Vue component instance */) {
|
2488 | 2504 |
|
2489 | 2505 | this.apps.push(app);
|
2490 | 2506 |
|
2491 |
| - // main app already initialized. |
| 2507 | + // set up app destroyed handler |
| 2508 | + // https://github.com/vuejs/vue-router/issues/2639 |
| 2509 | + app.$once('hook:destroyed', function () { |
| 2510 | + // clean out app from this.apps array once destroyed |
| 2511 | + var index = this$1.apps.indexOf(app); |
| 2512 | + if (index > -1) { this$1.apps.splice(index, 1); } |
| 2513 | + // ensure we still have a main app or null if no apps |
| 2514 | + // we do not release the router so it can be reused |
| 2515 | + if (this$1.app === app) { this$1.app = this$1.apps[0] || null; } |
| 2516 | + }); |
| 2517 | + |
| 2518 | + // main app previously initialized |
| 2519 | + // return as we don't need to set up new history listener |
2492 | 2520 | if (this.app) {
|
2493 | 2521 | return
|
2494 | 2522 | }
|
@@ -2622,7 +2650,7 @@ function createHref (base, fullPath, mode) {
|
2622 | 2650 | }
|
2623 | 2651 |
|
2624 | 2652 | VueRouter.install = install;
|
2625 |
| -VueRouter.version = '3.0.3'; |
| 2653 | +VueRouter.version = '3.0.4'; |
2626 | 2654 |
|
2627 | 2655 | if (inBrowser && window.Vue) {
|
2628 | 2656 | window.Vue.use(VueRouter);
|
|
0 commit comments