Sfoglia il codice sorgente

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 anni fa
parent
commit
c8294760b1
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  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;
 };