mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-17 14:54:30 +01:00
search.js: remove window.location.origin
workaround
This commit is contained in:
parent
eaf616c653
commit
12f510861b
@ -20,19 +20,6 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function getOrigin() {
|
|
||||||
var location = window.location
|
|
||||||
var origin = location.origin
|
|
||||||
|
|
||||||
if (!origin) {
|
|
||||||
var port = location.port ? ':' + location.port : ''
|
|
||||||
|
|
||||||
origin = location.protocol + '//' + location.hostname + port
|
|
||||||
}
|
|
||||||
|
|
||||||
return origin
|
|
||||||
}
|
|
||||||
|
|
||||||
window.docsearch({
|
window.docsearch({
|
||||||
apiKey: '5990ad008512000bba2cf951ccf0332f',
|
apiKey: '5990ad008512000bba2cf951ccf0332f',
|
||||||
indexName: 'bootstrap',
|
indexName: 'bootstrap',
|
||||||
@ -42,10 +29,9 @@
|
|||||||
},
|
},
|
||||||
transformData: function (hits) {
|
transformData: function (hits) {
|
||||||
return hits.map(function (hit) {
|
return hits.map(function (hit) {
|
||||||
var currentUrl = getOrigin()
|
|
||||||
var liveUrl = 'https://v5.getbootstrap.com/'
|
var liveUrl = 'https://v5.getbootstrap.com/'
|
||||||
|
|
||||||
hit.url = currentUrl.startsWith(liveUrl) ?
|
hit.url = window.location.origin.startsWith(liveUrl) ?
|
||||||
// On production, return the result as is
|
// On production, return the result as is
|
||||||
hit.url :
|
hit.url :
|
||||||
// On development or Netlify, replace `hit.url` with a trailing slash,
|
// On development or Netlify, replace `hit.url` with a trailing slash,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user