From c8294760b12fe5231e0c56b8ed1dc88d29668d57 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 11 Apr 2016 13:01:28 -0500 Subject: [PATCH] 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 --- include/webutil.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/webutil.js b/include/webutil.js index 4289aa6b..abb180a8 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; };