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:
parent
c03f302fa6
commit
112a35c08f
4 changed files with 33 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue