From 5cdf9628675b16f0b8f17ce298c638928c5baf18 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 23 Dec 2020 11:29:24 +0800 Subject: [PATCH] =?UTF-8?q?BI-78918=20fix:=20=E8=A7=A3=E7=A0=81=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/router.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/router/router.js b/src/router/router.js index 76504dffd..3eb63bd12 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -298,7 +298,14 @@ return _.map(params, function (param, i) { // Don't decode the search params. if (i === params.length - 1) return param || null; - return param ? decodeURIComponent(param) : null; + var resultParam = null; + if (param) { + try { + resultParam = decodeURIComponent(param); + } catch (e) { + } + } + return resultParam; }); } @@ -364,7 +371,11 @@ // Get the pathname and search params, without the root. getPath: function () { - var path = decodeURI(this.location.pathname + this.getSearch()); + var path = this.location.pathname + this.getSearch(); + try { + path = decodeURI(path); + } catch(e) { + } var root = this.root.slice(0, -1); if (!path.indexOf(root)) path = path.slice(root.length); return path.charAt(0) === "/" ? path.slice(1) : path; @@ -552,7 +563,11 @@ var url = root + fragment; // Strip the hash and decode for matching. - fragment = decodeURI(fragment.replace(pathStripper, "")); + fragment = fragment.replace(pathStripper, "") + try { + fragment = decodeURI(fragment); + } catch(e) { + } if (this.fragment === fragment) return; this.fragment = fragment;