Improving the generated search urls.

This commit is contained in:
Sergiotarxz 2023-09-05 16:42:58 +02:00
parent 9f8a281b6a
commit 96b403ff87
2 changed files with 11 additions and 4 deletions

View File

@ -73,11 +73,14 @@ function onSearchChange() {
}
const query = search.value;
fakeSearchInput.value = search.value
let port = window.location.port;
if (port !== '') {
port = ':' + port
}
const url = new URL(window.location.protocol
+ "//"
+ window.location.hostname
+ ":"
+ window.location.port
+ port
+ '/search.json');
url.searchParams.set('q', query);
fetch(url).then(async (res) => {
@ -106,10 +109,14 @@ function showResults(searchResults, searchObjects) {
const content = document.createElement('p')
title.innerText = searchObject.title
let port = window.location.port;
if (port !== '') {
port = ':' + port
}
if (searchObject.url.match(/^\//)) {
searchObject.url = window.location.protocol
+ "//" + window.location.hostname
+ ":" + window.location.port
+ port
+ searchObject.url
}
url.href = searchObject.url

File diff suppressed because one or more lines are too long