Skip to content

Commit

Permalink
search.js: remove window.location.origin workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Nov 14, 2020
1 parent eaf616c commit 12f5108
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions site/assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
apiKey: '5990ad008512000bba2cf951ccf0332f',
indexName: 'bootstrap',
Expand All @@ -42,10 +29,9 @@
},
transformData: function (hits) {
return hits.map(function (hit) {
var currentUrl = getOrigin()
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
hit.url :
// On development or Netlify, replace `hit.url` with a trailing slash,
Expand Down

0 comments on commit 12f5108

Please sign in to comment.