Browse Source

BI-78918 fix: 解码报错问题

es6
windy 4 years ago
parent
commit
5cdf962867
  1. 21
      src/router/router.js

21
src/router/router.js

@ -298,7 +298,14 @@
return _.map(params, function (param, i) { return _.map(params, function (param, i) {
// Don't decode the search params. // Don't decode the search params.
if (i === params.length - 1) return param || null; 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. // Get the pathname and search params, without the root.
getPath: function () { 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); var root = this.root.slice(0, -1);
if (!path.indexOf(root)) path = path.slice(root.length); if (!path.indexOf(root)) path = path.slice(root.length);
return path.charAt(0) === "/" ? path.slice(1) : path; return path.charAt(0) === "/" ? path.slice(1) : path;
@ -552,7 +563,11 @@
var url = root + fragment; var url = root + fragment;
// Strip the hash and decode for matching. // 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; if (this.fragment === fragment) return;
this.fragment = fragment; this.fragment = fragment;

Loading…
Cancel
Save