summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bennett <jbennett@incomsystems.biz>2016-04-11 13:01:28 -0500
committerJonathan Bennett <jbennett@incomsystems.biz>2016-04-12 11:00:28 -0500
commitc8294760b12fe5231e0c56b8ed1dc88d29668d57 (patch)
tree0023bee561c606e861b86b4f3d899ca0904afe0a
parentb403cb92fb8de82d04f305b4f14fa978003890d7 (diff)
downloadnovnc-c8294760b12fe5231e0c56b8ed1dc88d29668d57.tar.gz
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
-rw-r--r--include/webutil.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/webutil.js b/include/webutil.js
index 4289aa6..abb180a 100644
--- a/include/webutil.js
+++ b/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;
};