From 65b795a8ea7f41691142ba0ba880524838104bce Mon Sep 17 00:00:00 2001 From: Carlos Polop Date: Mon, 21 Apr 2025 02:10:13 +0200 Subject: [PATCH] fix search --- theme/ht_searcher.js | 70 ++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/theme/ht_searcher.js b/theme/ht_searcher.js index c748aab14..9e6e0b184 100644 --- a/theme/ht_searcher.js +++ b/theme/ht_searcher.js @@ -471,39 +471,53 @@ window.search = window.search || {}; showResults(true); } - (async function loadSearchIndex(lang = window.lang || 'en') { - /* ───────── paths ───────── */ - const branch = lang === 'en' ? 'master' : lang; - const baseRemote = `https://raw.githubusercontent.com/HackTricks-wiki/hacktricks/refs/heads/${branch}`; - const remoteJs = `${baseRemote}/searchindex.js`; - const localJs = '/searchindex.js'; - const TIMEOUT_MS = 5_000; - - const loadScript = src => - new Promise((resolve, reject) => { - const s = document.createElement('script'); - s.src = src; - s.onload = resolve; - s.onerror = reject; + (async function loadSearchIndex(lang = window.lang || "en") { + const branch = lang === "en" ? "master" : lang; + const rawUrl = + `https://raw.githubusercontent.com/HackTricks-wiki/hacktricks/refs/heads/${branch}/searchindex.js`; + const localJs = "/searchindex.js"; + const TIMEOUT_MS = 5_000; + + /* helper: inject a