Skip to content

Commit 41eb94b

Browse files
committed
Ensure variable is defined
1 parent 8c5ba34 commit 41eb94b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

spec/_static/javascripts/version_dropdown.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ function add_version_dropdown(json_loc, target_loc, text) {
2222
$.getJSON(json_loc, function(versions) {
2323
var currentURL = window.location.href;
2424
var path = currentURL.split("_site")[1];
25-
path = path.split("/");
26-
path = path.slice(2, path.length);
27-
path = path.join("/");
28-
for (var key in versions) {
29-
if (versions.hasOwnProperty(key)) {
30-
var a = document.createElement("a");
31-
a.innerHTML = key;
32-
a.title = key;
33-
assign_href(a, target_loc + versions[key], path);
34-
content.appendChild(a);
25+
if (path) {
26+
path = path.split("/");
27+
path = path.slice(2, path.length);
28+
path = path.join("/");
29+
for (var key in versions) {
30+
if (versions.hasOwnProperty(key)) {
31+
var a = document.createElement("a");
32+
a.innerHTML = key;
33+
a.title = key;
34+
assign_href(a, target_loc + versions[key], path);
35+
content.appendChild(a);
36+
}
3537
}
3638
}
3739
}).done(function() {

0 commit comments

Comments
 (0)