Handle missing leading slash in elem.pathname

IE11 with compat mode turned off has been observed displaying this behavior.  This commit checks for and corrects this broken behavior.

Fixes #591
This commit is contained in:
Jonathan Bennett 2016-04-11 13:01:28 -05:00
parent b403cb92fb
commit c8294760b1
1 changed files with 6 additions and 1 deletions

View File

@ -282,5 +282,10 @@ WebUtil.injectParamIfMissing = function (path, param, value) {
elem.search = "?" + query.join("&");
}
return elem.pathname.slice(1) + elem.search + elem.hash;
// some browsers (e.g. IE11) may occasionally omit the leading slash
// in the elem.pathname string. Handle that case gracefully.
if (elem.pathname.charAt(0) == "/") {
return elem.pathname.slice(1) + elem.search + elem.hash;
} else {
return elem.pathname + elem.search + elem.hash;
};