]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Update search.js
authorXhmikosR <xhmikosr@gmail.com>
Mon, 17 Feb 2020 16:33:57 +0000 (18:33 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 12 Mar 2024 05:28:25 +0000 (07:28 +0200)
site/assets/js/search.js

index 8ff2f934c5a7bdcba4e48bbb0c55deed8b9dcad6..ad9cb6983e6da9bb7ae8d03068b8503e63c6a266 100644 (file)
   })
 
   function hashSearch() {
-    if (window.location.hash && window.location.hash.indexOf('#search=') === 0) {
-      search.input.autocomplete.setVal(window.location.hash.slice(8))
+    const SEARCH_WORD = '#search='
+
+    if (window.location.hash && window.location.hash.startsWith(SEARCH_WORD)) {
+      search.input.autocomplete.setVal(window.location.hash.slice(SEARCH_WORD.length))
       search.input.autocomplete.open()
     }
   }
 
   hashSearch()
+
   // For the nerds: search by changing the url hash
   window.addEventListener('hashchange', hashSearch, false)
 })()