Skip to content

Commit c2c5e4a

Browse files
committed
added escaping for regex characters
1 parent 58aabfe commit c2c5e4a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/default/lwc/lookup/lookup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export default class Lookup extends LightningElement {
5858
// Clone results before modifying them to avoid Locker restriction
5959
const resultsLocal = JSON.parse(JSON.stringify(results));
6060
// Format results
61-
const regex = new RegExp(`(${this._searchTerm})`, 'gi');
61+
const escapedSearchTerm = this._searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
62+
const regex = new RegExp(`(${escapedSearchTerm})`, 'gi');
6263

6364
const splicedResults = resultsLocal.splice(0, this.maxDisplayedResults);
6465

0 commit comments

Comments
 (0)