From abc2ec49a9ef388bffc88a955cad9fccd538e10c Mon Sep 17 00:00:00 2001 From: Folyd Date: Tue, 13 Feb 2024 23:33:10 -0800 Subject: [PATCH] Load search index for rustc --- extension/script/add-search-index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/extension/script/add-search-index.js b/extension/script/add-search-index.js index 2f432e99..10f6c087 100644 --- a/extension/script/add-search-index.js +++ b/extension/script/add-search-index.js @@ -69,15 +69,22 @@ } if (searchIndexJs) { - let script = document.createElement('script'); - script.src = searchIndexJs; - script.onload = sendSearchIndex; - document.head.append(script); + if (location.pathname.startsWith("/nightly/nightly-rustc/")) { + loadSearchIndex("/nightly/nightly-rustc/search-index.js"); + } else { + loadSearchIndex(searchIndexJs); + } } else { console.error("Sorry, no search index found."); } } + function loadSearchIndex(searchIndexJs) { + let script = document.createElement('script'); + script.src = searchIndexJs; + script.onload = sendSearchIndex; + document.head.append(script); + } // [rustdoc] Use Map instead of Object for source files and search index #118910 // https://github.com/rust-lang/rust/pull/118910