]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
search.js: make the check for URL stricter (#30695)
authorXhmikosR <xhmikosr@gmail.com>
Thu, 30 Apr 2020 18:07:26 +0000 (21:07 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Sat, 2 May 2020 12:39:19 +0000 (15:39 +0300)
site/docs/4.4/assets/js/src/search.js

index dd2a90e58779d06a4b57906379504483062f3a46..e372d155374ff89ca8084973c5acf5967b57c5b3 100644 (file)
     transformData: function (hits) {
       return hits.map(function (hit) {
         var currentUrl = getOrigin()
-        var liveUrl = 'https://getbootstrap.com'
+        var liveUrl = 'https://getbootstrap.com/'
 
-        // When in production, return the result as is,
-        // otherwise remove our url from it.
-        // eslint-disable-next-line no-negated-condition
-        hit.url = currentUrl.indexOf(liveUrl) !== -1
+        hit.url = currentUrl.lastIndexOf(liveUrl, 0) === 0
+          // On production, return the result as is
           ? hit.url
-          : hit.url.replace(liveUrl, '')
+          // On development or Netlify, replace `hit.url` with a trailing slash,
+          // so that the result link is relative to the server root
+          : hit.url.replace(liveUrl, '/')
 
         // Prevent jumping to first header
         if (hit.anchor === 'content') {