mirror of
https://github.com/pawelmalak/flame.git
synced 2026-03-10 06:23:11 +08:00
Adding a default search provider option, with DuckDuckGo as the default
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user