Improving the generated search urls.
This commit is contained in:
parent
9f8a281b6a
commit
96b403ff87
@ -73,11 +73,14 @@ function onSearchChange() {
|
|||||||
}
|
}
|
||||||
const query = search.value;
|
const query = search.value;
|
||||||
fakeSearchInput.value = search.value
|
fakeSearchInput.value = search.value
|
||||||
|
let port = window.location.port;
|
||||||
|
if (port !== '') {
|
||||||
|
port = ':' + port
|
||||||
|
}
|
||||||
const url = new URL(window.location.protocol
|
const url = new URL(window.location.protocol
|
||||||
+ "//"
|
+ "//"
|
||||||
+ window.location.hostname
|
+ window.location.hostname
|
||||||
+ ":"
|
+ port
|
||||||
+ window.location.port
|
|
||||||
+ '/search.json');
|
+ '/search.json');
|
||||||
url.searchParams.set('q', query);
|
url.searchParams.set('q', query);
|
||||||
fetch(url).then(async (res) => {
|
fetch(url).then(async (res) => {
|
||||||
@ -106,10 +109,14 @@ function showResults(searchResults, searchObjects) {
|
|||||||
const content = document.createElement('p')
|
const content = document.createElement('p')
|
||||||
|
|
||||||
title.innerText = searchObject.title
|
title.innerText = searchObject.title
|
||||||
|
let port = window.location.port;
|
||||||
|
if (port !== '') {
|
||||||
|
port = ':' + port
|
||||||
|
}
|
||||||
if (searchObject.url.match(/^\//)) {
|
if (searchObject.url.match(/^\//)) {
|
||||||
searchObject.url = window.location.protocol
|
searchObject.url = window.location.protocol
|
||||||
+ "//" + window.location.hostname
|
+ "//" + window.location.hostname
|
||||||
+ ":" + window.location.port
|
+ port
|
||||||
+ searchObject.url
|
+ searchObject.url
|
||||||
}
|
}
|
||||||
url.href = searchObject.url
|
url.href = searchObject.url
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user