1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-21 04:19:37 +02:00

Adding a default search provider option, with DuckDuckGo as the default

This commit is contained in:
Jeremy Jack 2021-07-05 23:04:03 -05:00
parent c03f302fa6
commit 112a35c08f
4 changed files with 33 additions and 7 deletions

View file

@ -4,12 +4,13 @@ import { Query } from '../interfaces';
import { searchConfig } from '.';
export const searchParser = (searchQuery: string): boolean => {
const space = searchQuery.indexOf(' ');
const prefix = searchQuery.slice(1, space);
const search = encodeURIComponent(searchQuery.slice(space + 1));
const splitQuery = searchQuery.match(/^\/([a-z]+)[ ](.+)$/i);
const prefix = splitQuery ? splitQuery[1] : searchConfig('defaultSearchProvider', 'd');
const search = splitQuery ? encodeURIComponent(splitQuery[2]) : encodeURIComponent(searchQuery);
const query = queries.find((q: Query) => q.prefix === prefix);
console.log("QUERY IS " + query);
if (query) {
const sameTab = searchConfig('searchSameTab', false);
@ -23,4 +24,4 @@ export const searchParser = (searchQuery: string): boolean => {
}
return false;
}
}