diff --git a/docs/assets/js/version-selector.js b/docs/assets/js/version-selector.js index 59862c049..5eebc8196 100644 --- a/docs/assets/js/version-selector.js +++ b/docs/assets/js/version-selector.js @@ -22,8 +22,18 @@ let populateSelect = function (versions) { selects.forEach(select => { select.addEventListener('change', (e) => { - let path = e.target.selectedIndex === 0 ? '/' : e.target.value - window.location.href = path + if (e.target.selectedIndex === 0) { + // Remove version in path + window.location.href = window.location.origin + + window.location.pathname + .split('/') + .filter(part => !part.match(/\d+\.\d+\.\d+/g)) + .join('/') + } else { + // Add version to path + window.location.href = + window.location.origin + e.target.value + window.location.pathname + } }) }) }