From: XhmikosR Date: Thu, 30 Apr 2020 18:07:26 +0000 (+0300) Subject: search.js: make the check for URL stricter (#30695) X-Git-Tag: v4.5.0~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=63dbe4705d5b7c962b74f0e64156b0124b89739c;p=thirdparty%2Fbootstrap.git search.js: make the check for URL stricter (#30695) --- diff --git a/site/docs/4.4/assets/js/src/search.js b/site/docs/4.4/assets/js/src/search.js index dd2a90e587..e372d15537 100644 --- a/site/docs/4.4/assets/js/src/search.js +++ b/site/docs/4.4/assets/js/src/search.js @@ -35,14 +35,14 @@ 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') {