From 3adfed47524ae49f28f0a12d080561dc377b40b9 Mon Sep 17 00:00:00 2001 From: Bastian Meissner Date: Sun, 24 May 2020 15:16:20 +0200 Subject: [PATCH] Fixed search bar --- README.md | 2 ++ src/components/searchBar.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ce4a054..6062b71 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Getting Dashboard to run is fairly simple and can be accomplished with two techn 1. Locally +Prerequisites: yarn, npm, node + ``` $ git clone https://github.com/phntxx/dashboard.git $ cd dashboard/ diff --git a/src/components/searchBar.js b/src/components/searchBar.js index e577d8e..57e4290 100644 --- a/src/components/searchBar.js +++ b/src/components/searchBar.js @@ -51,10 +51,12 @@ const SearchBar = () => { const handleSearchQuery = e => { var query = input; + console.log(query); + if (query.split(' ')[0].includes('/')) { handleQueryWithProvider(query); } else { - window.location = 'https://google.com/search?q=' + query; + //window.location = 'https://google.com/search?q=' + query; } e.preventDefault(); @@ -67,12 +69,16 @@ const SearchBar = () => { let searchQuery = queryArray.join(' '); + let providerFound = false; providers.forEach(provider => { - if (provider.prefix === prefix) + if (provider.prefix === prefix) { + providerFound = true; window.location = provider.url + searchQuery; + } }); - window.location = 'https://google.com/search?q=' + query; + if (!providerFound) + window.location = 'https://google.com/search?q=' + query; }; return (