about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-02-17 20:24:50 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2021-02-17 22:04:30 +0100
commiteeb555266764069937491a26e817d4bcfea5da3a (patch)
tree80ec9983e3963c03043cf480690e87664a48b041
parent323fb7113bc64886205047c97423882a7f8162f2 (diff)
downloadrust-eeb555266764069937491a26e817d4bcfea5da3a.tar.gz
rust-eeb555266764069937491a26e817d4bcfea5da3a.zip
Remove query parameters when leaving search results
-rw-r--r--src/librustdoc/html/static/main.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index ec89ae0228c..e8daa8414a2 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -101,7 +101,7 @@ function focusSearchBar() {
     getSearchInput().focus();
 }
 
-// Removes the focus from the search bar
+// Removes the focus from the search bar.
 function defocusSearchBar() {
     getSearchInput().blur();
 }
@@ -220,6 +220,11 @@ function defocusSearchBar() {
         addClass(search, "hidden");
         removeClass(main, "hidden");
         document.title = titleBeforeSearch;
+        // We also remove the query parameter from the URL.
+        if (browserSupportsHistoryApi()) {
+            history.replaceState("", window.currentCrate + " - Rust",
+                getNakedUrl() + window.location.hash);
+        }
     }
 
     // used for special search precedence