Skip to content

Commit c0a4553

Browse files
committed
fixed base path calculation for versions.json URL
1 parent 96be946 commit c0a4553

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

docs/assets/js/scripts.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
document.addEventListener("DOMContentLoaded", function() {
2-
const base_url = window.location.pathname.split('/')[1];
3-
const json_url = '/' + base_url + "/versions.json";
2+
const path = window.location.pathname;
3+
const match = path.match(/(.*\/)(?:v?\d+\.\d+|latest)\//);
4+
const base_path = match ? match[1] : path.substring(0, path.lastIndexOf('/') + 1);
5+
const json_url = `${base_path}versions.json`;
46
const stargazers_element = document.querySelector('header div div:nth-child(3) a');
57

68
if (!stargazers_element) {

0 commit comments

Comments
 (0)