Skip to content

Commit

Permalink
fix: fetchSearchResultsWithoutNumber regex
Browse files Browse the repository at this point in the history
The regex only replaced the last number and not the whole
sequence of numbers. This makes it work somewhat randomly, sometimes
the dispatcher manages to re-trigger without sending any requests but
in production it looks like the original version removes one digit and
does a request and repeats it until there are no more suffix digits.

refs: PL-32
  • Loading branch information
voneiden committed Jan 8, 2025
1 parent c7b4b76 commit 5c11d95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/views/SearchView/SearchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ function SearchView() {
// Check if search query ends with number and fetch data without it.
// This is for searching addresses with street number in case of no results.
if (searchQuery && searchQuery.match(/\d$/)) {
const newSearchQuery = searchQuery.replace(/\d$/, '');
if (newSearchQuery !== searchQuery) {
const newSearchQuery = searchQuery.replace(/\d+$/, '');
if (newSearchQuery && newSearchQuery !== searchQuery) {
dispatch(fetchSearchResults({ q: newSearchQuery }));
}
}
Expand Down

0 comments on commit 5c11d95

Please sign in to comment.