Fixed search bar

This commit is contained in:
Bastian Meissner 2020-05-24 15:16:20 +02:00
parent 22ee2ca08d
commit 3adfed4752
2 changed files with 11 additions and 3 deletions

View file

@ -18,6 +18,8 @@ Getting Dashboard to run is fairly simple and can be accomplished with two techn
1. Locally 1. Locally
Prerequisites: yarn, npm, node
``` ```
$ git clone https://github.com/phntxx/dashboard.git $ git clone https://github.com/phntxx/dashboard.git
$ cd dashboard/ $ cd dashboard/

View file

@ -51,10 +51,12 @@ const SearchBar = () => {
const handleSearchQuery = e => { const handleSearchQuery = e => {
var query = input; var query = input;
console.log(query);
if (query.split(' ')[0].includes('/')) { if (query.split(' ')[0].includes('/')) {
handleQueryWithProvider(query); handleQueryWithProvider(query);
} else { } else {
window.location = 'https://google.com/search?q=' + query; //window.location = 'https://google.com/search?q=' + query;
} }
e.preventDefault(); e.preventDefault();
@ -67,12 +69,16 @@ const SearchBar = () => {
let searchQuery = queryArray.join(' '); let searchQuery = queryArray.join(' ');
let providerFound = false;
providers.forEach(provider => { providers.forEach(provider => {
if (provider.prefix === prefix) if (provider.prefix === prefix) {
providerFound = true;
window.location = provider.url + searchQuery; window.location = provider.url + searchQuery;
}
}); });
window.location = 'https://google.com/search?q=' + query; if (!providerFound)
window.location = 'https://google.com/search?q=' + query;
}; };
return ( return (