mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
search.js: make the check for URL stricter (#30695)
This commit is contained in:
parent
3e73039936
commit
81404d2e3c
1 changed files with 6 additions and 6 deletions
|
@ -35,14 +35,14 @@
|
||||||
transformData: function (hits) {
|
transformData: function (hits) {
|
||||||
return hits.map(function (hit) {
|
return hits.map(function (hit) {
|
||||||
var currentUrl = getOrigin()
|
var currentUrl = getOrigin()
|
||||||
var liveUrl = 'https://getbootstrap.com'
|
var liveUrl = 'https://getbootstrap.com/'
|
||||||
|
|
||||||
// When in production, return the result as is,
|
hit.url = currentUrl.lastIndexOf(liveUrl, 0) === 0 ?
|
||||||
// otherwise remove our url from it.
|
// On production, return the result as is
|
||||||
// eslint-disable-next-line no-negated-condition
|
|
||||||
hit.url = currentUrl.indexOf(liveUrl) !== -1 ? // lgtm [js/incomplete-url-substring-sanitization]
|
|
||||||
hit.url :
|
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
|
// Prevent jumping to first header
|
||||||
if (hit.anchor === 'content') {
|
if (hit.anchor === 'content') {
|
||||||
|
|
Loading…
Reference in a new issue