Skip to content

Commit dd313a1

Browse files
authored
fix: special chars in showSearchBox (#410)
1 parent 56c543b commit dd313a1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: src/components/vue-tel-input.vue

+6-3
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,13 @@ export default {
236236
if (!this.dropdownOptions.showSearchBox) {
237237
return countriesList;
238238
}
239+
const userInput = this.searchQuery;
240+
const cleanInput = userInput.replace(/[~`!@#$%^&*()+={}\[\];:\'\"<>.,\/\\\?-_]/g, '');
241+
239242
return countriesList.filter(
240-
(c) => (new RegExp(this.searchQuery, 'i')).test(c.name)
241-
|| (new RegExp(this.searchQuery, 'i')).test(c.iso2)
242-
|| (new RegExp(this.searchQuery, 'i')).test(c.dialCode),
243+
(c) => (new RegExp(cleanInput, 'i')).test(c.name)
244+
|| (new RegExp(cleanInput, 'i')).test(c.iso2)
245+
|| (new RegExp(cleanInput, 'i')).test(c.dialCode),
243246
);
244247
},
245248
phoneObject() {

0 commit comments

Comments
 (0)