From 845e59cf0b7a65971b2c8503d342a229c12095dc Mon Sep 17 00:00:00 2001 From: Manu Date: Thu, 20 Feb 2020 17:55:42 +0100 Subject: [PATCH] fix(frontend): query is not a regexp (#2393) --- .../src/search/SearchBar/DocumentSuggester.js | 3 +-- .../code-du-travail-frontend/src/search/SearchBar/index.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/code-du-travail-frontend/src/search/SearchBar/DocumentSuggester.js b/packages/code-du-travail-frontend/src/search/SearchBar/DocumentSuggester.js index b157b50f7c..ffd13a6b74 100644 --- a/packages/code-du-travail-frontend/src/search/SearchBar/DocumentSuggester.js +++ b/packages/code-du-travail-frontend/src/search/SearchBar/DocumentSuggester.js @@ -117,8 +117,7 @@ const SuggestionContainer = styled.div` `; const renderSuggestion = (suggestion, query) => { - const regexp = new RegExp(query); - const title = suggestion.replace(regexp, "$&"); + const title = suggestion.replace(query, `${query}`); return ( {title} diff --git a/packages/code-du-travail-frontend/src/search/SearchBar/index.js b/packages/code-du-travail-frontend/src/search/SearchBar/index.js index b43d91bd59..197a74c5a2 100644 --- a/packages/code-du-travail-frontend/src/search/SearchBar/index.js +++ b/packages/code-du-travail-frontend/src/search/SearchBar/index.js @@ -34,7 +34,7 @@ const SearchBar = ({ router.push({ pathname: "/recherche", query: { - q: query + q: query.trim() } }); }