Skip to content

Commit eeb5552

Browse files
Remove query parameters when leaving search results
1 parent 323fb71 commit eeb5552

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustdoc/html/static/main.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function focusSearchBar() {
101101
getSearchInput().focus();
102102
}
103103

104-
// Removes the focus from the search bar
104+
// Removes the focus from the search bar.
105105
function defocusSearchBar() {
106106
getSearchInput().blur();
107107
}
@@ -220,6 +220,11 @@ function defocusSearchBar() {
220220
addClass(search, "hidden");
221221
removeClass(main, "hidden");
222222
document.title = titleBeforeSearch;
223+
// We also remove the query parameter from the URL.
224+
if (browserSupportsHistoryApi()) {
225+
history.replaceState("", window.currentCrate + " - Rust",
226+
getNakedUrl() + window.location.hash);
227+
}
223228
}
224229

225230
// used for special search precedence

0 commit comments

Comments
 (0)