ソースを参照

Merge pull request #597 from oneru/master

Handle missing leading slash in elem.pathname
Solly Ross 9 年 前
コミット
bf0ce0ba3c
1 ファイル変更6 行追加1 行削除
  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;
 };