about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-03-30 13:59:10 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2020-07-02 13:19:04 +0200
commit0fcb7dabac1409f4ff51867aa5e9e0e51ec6e248 (patch)
treeaef06dec4aad97693f23b6eaa60d521ca03d2907
parentd5141e6829f9eeb54f3165bcd1548883713ef81c (diff)
downloadrust-0fcb7dabac1409f4ff51867aa5e9e0e51ec6e248.tar.gz
rust-0fcb7dabac1409f4ff51867aa5e9e0e51ec6e248.zip
Improve page hash handling
-rw-r--r--src/librustdoc/html/static/main.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 3003ad1d560..93929a67d49 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -112,9 +112,11 @@ function defocusSearchBar() {
     }
 
     function getPageId() {
-        var id = document.location.href.split("#")[1];
-        if (id) {
-            return id.split("?")[0].split("&")[0];
+        if (window.location.hash) {
+            var tmp = window.location.hash.replace(/^#/, "");
+            if (tmp.length > 0) {
+                return tmp;
+            }
         }
         return null;
     }
@@ -2688,8 +2690,8 @@ function defocusSearchBar() {
 
     autoCollapse(pageId, getCurrentValue("rustdoc-collapse") === "true");
 
-    if (window.location.hash && window.location.hash.length > 0) {
-        expandSection(window.location.hash.replace(/^#/, ""));
+    if (pageId !== null) {
+        expandSection(pageId);
     }
 
     if (main) {