diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 74bd348e9ac..5606a1d5170 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1925,7 +1925,8 @@ function defocusSearchBar() {
clearInputTimeout();
if (search_input.value.length === 0) {
if (browserSupportsHistoryApi()) {
- history.replaceState("", window.currentCrate + " - Rust", "?search=");
+ history.replaceState("", window.currentCrate + " - Rust",
+ window.location.href.split("?")[0]);
}
hideSearchResults();
} else {