Prechádzať zdrojové kódy

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
Jonathan Bennett 9 rokov pred
rodič
commit
c8294760b1
1 zmenil súbory, kde vykonal 6 pridanie a 1 odobranie
  1. 6 1
      include/webutil.js

+ 6 - 1
include/webutil.js

@@ -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;
 };