aboutsummaryrefslogtreecommitdiff
path: root/site/docs
diff options
context:
space:
mode:
Diffstat (limited to 'site/docs')
-rw-r--r--site/docs/4.1/assets/js/src/search.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/site/docs/4.1/assets/js/src/search.js b/site/docs/4.1/assets/js/src/search.js
index 2e91fcf21..546cca5c7 100644
--- a/site/docs/4.1/assets/js/src/search.js
+++ b/site/docs/4.1/assets/js/src/search.js
@@ -12,6 +12,19 @@
var inputElement = document.getElementById('search-input')
var siteDocsVersion = inputElement.getAttribute('data-docs-version')
+ 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',
@@ -27,11 +40,11 @@
},
transformData: function (hits) {
return hits.map(function (hit) {
- // When in production, return the result as is,
- // otherwise remove our url from it.
- var siteurl = inputElement.getAttribute('data-siteurl')
+ var siteurl = getOrigin()
var urlRE = /^https?:\/\/getbootstrap\.com/
+ // When in production, return the result as is,
+ // otherwise remove our url from it.
hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '')
return hit