Skip to content

Commit 40a2c14

Browse files
committed
cards.js: Now, hosts can be compared
1 parent 95081a5 commit 40a2c14

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

docs/js/cards.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ $(function() {
88
destUrl = document.location.protocol + '//' + document.location.host + destUrl;
99
}
1010
destUrl = new URL(destUrl);
11-
let destPath = destUrl.pathname.split('/'),
12-
srcPath = document.location.pathname.split('/');
13-
if (destPath[version_path_index] !== srcPath[version_path_index]) {
14-
destPath[version_path_index] = srcPath[version_path_index];
11+
if (destUrl.host === document.location.host) {
12+
let destPath = destUrl.pathname.split('/'),
13+
srcPath = document.location.pathname.split('/');
14+
if (destPath[version_path_index] !== srcPath[version_path_index]) {
15+
destPath[version_path_index] = srcPath[version_path_index];
16+
}
17+
destUrl.pathname = destPath.join('/');
18+
$(this).attr('href', destUrl.pathname);
1519
}
16-
destUrl.pathname = destPath.join('/');
17-
$(this).attr('href', destUrl.href);
1820
});
1921
});

0 commit comments

Comments
 (0)