Skip to content

Commit 360ab51

Browse files
authored
fix version dropdown change (#254)
1 parent bb820e8 commit 360ab51

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ui/templates/partials/cookbook/header.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ <h1 class="cookbook-headline">
3838
);
3939

4040
function changeUrl(v) {
41-
const searchTerm = window.location.pathname.includes("/_latest/") ? "/_latest/" : '/{{.cookbook.Metadata.Version}}/'
42-
window.location.href = window.location.pathname.replace(searchTerm, '/' + v + '/');
41+
const latestPath = '/{{.cookbook.Metadata.Name}}/_latest';
42+
const versionedPath = '/{{.cookbook.Metadata.Name}}/{{.cookbook.Metadata.Version}}';
43+
const currentPath = window.location.pathname;
44+
const searchTerm = currentPath.includes(latestPath) ? latestPath : versionedPath;
45+
window.location.href = currentPath.replace(searchTerm, '/{{.cookbook.Metadata.Name}}/'+v);
4346
}
4447
</script>
4548
<div class="col">

0 commit comments

Comments
 (0)