Skip to content

Commit

Permalink
fix: search term validation
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsalsinghkv committed Oct 4, 2023
1 parent 869b4a1 commit bb85c0f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ function App() {
// const {value}=input.target;
setSearchTerm(input);

if (!input) {
if (!input.trim()) {
// created if-else loop for matching countries according to the input
setCountryMatch([]);
} else {
let matches = countries.filter((country) => {
// eslint-disable-next-line no-template-curly-in-string
const regex = new RegExp(`${input}`, 'gi');
const regex = new RegExp(`${input.trim()}`, 'gi');
// console.log(regex)
return country.match(regex) || country.match(regex);
});
Expand Down

0 comments on commit bb85c0f

Please sign in to comment.