Skip to content

Commit

Permalink
fix: Use window.location.pathname if anchor pathname is empty (IE11)
Browse files Browse the repository at this point in the history
IE11 will return an empty pathname for anchors where the href attribute
contains a relative link consisting of only a query parameter
(e.g. "?search=test"). This will not fix cases where the relative link
contains a relative path (e.g. "foo/bar.html").
  • Loading branch information
Christof Luick committed May 16, 2018
1 parent 043e68c commit 63957ed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion page.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,18 @@ pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
// rebuild path
// There aren't .pathname and .search properties in svg links, so we use href
// Also, svg href is an object and its desired value is in .baseVal property
var path = svg ? el.href.baseVal : (el.pathname + el.search + (el.hash || ''));
var path
if (svg) {
path = el.href.baseVal
} else {
var pathname = el.pathname
if (!pathname) {
// In IE11 pathname contains an empty string for
// relative links. Use window.location.pathname instead.
pathname = window.location.pathname
}
path = pathname + el.search + (el.hash || '')
}

path = path[0] !== '/' ? '/' + path : path;

Expand Down

0 comments on commit 63957ed

Please sign in to comment.