Skip to content

Commit

Permalink
Prefix sample type menu entry ids with "sampletype-". (#792)
Browse files Browse the repository at this point in the history
Previously, we would use the sample type name as the HTML id for the
corresponding menu entry. However some profiles contain sample type
names that conflict with other HTML ids we use (in particular, the
sample type name "sample" conflicted with a different id). Remove this
name clash by prefixing every menu entry with "sampletype-".

some profiles caused the Javascript to break bec
  • Loading branch information
ghemawat authored Aug 8, 2023
1 parent 2ba5b33 commit 4887780
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/driver/html/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,11 @@ function viewer(baseUrl, nodes, options) {
return str.replace(/([\\\.?+*\[\](){}|^$])/g, '\\$1');
}

function setSampleIndexLink(id) {
const elem = document.getElementById(id);
function setSampleIndexLink(si) {
const elem = document.getElementById('sampletype-' + si);
if (elem != null) {
setHrefParams(elem, function (params) {
params.set("si", id);
params.set("si", si);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/html/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1><a href="./">pprof</a></h1>
</div>
<div class="submenu">
{{range .SampleTypes}}
<a href="?si={{.}}" id="{{.}}">{{.}}</a>
<a href="?si={{.}}" id="sampletype-{{.}}">{{.}}</a>
{{end}}
</div>
</div>
Expand Down

0 comments on commit 4887780

Please sign in to comment.