diff --git a/flow-typed/search.js b/flow-typed/search.js index e1fa45f27..2697bdd0a 100644 --- a/flow-typed/search.js +++ b/flow-typed/search.js @@ -17,6 +17,7 @@ declare type SearchOptions = { SORT: string, SORT_ACCENDING: string, SORT_DESCENDING: string, + EXACT: string, }; declare type SearchState = { diff --git a/ui/constants/search.js b/ui/constants/search.js index b0d28faee..7251ba6ff 100644 --- a/ui/constants/search.js +++ b/ui/constants/search.js @@ -24,4 +24,5 @@ export const SEARCH_OPTIONS = { SORT: 'sort_by', SORT_ACCENDING: '^release_time', SORT_DESCENDING: 'release_time', + EXACT: 'exact', }; diff --git a/ui/util/query-params.js b/ui/util/query-params.js index 371370c70..cbafd9ac1 100644 --- a/ui/util/query-params.js +++ b/ui/util/query-params.js @@ -34,9 +34,10 @@ export function updateQueryParam(uri: string, key: string, value: string) { export const getSearchQueryString = (query: string, options: any = {}) => { const FORCE_FREE_ONLY = SIMPLE_SITE; + const isSurroundedByQuotes = (str) => str[0] === '"' && str[str.length - 1] === '"'; const encodedQuery = encodeURIComponent(query); const queryParams = [ - `s=${encodedQuery}`, + options.exact && !isSurroundedByQuotes(encodedQuery) ? `s="${encodedQuery}"` : `s=${encodedQuery}`, `size=${options.size || DEFAULT_SEARCH_SIZE}`, `from=${options.from || DEFAULT_SEARCH_RESULT_FROM}`, ];