Skip to content

Commit 090009a

Browse files
authored
Merge pull request github#26791 from github/repo-sync
repo sync
2 parents cb29d44 + 3fd1650 commit 090009a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/landing/CodeExamples.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export const CodeExamples = () => {
2222
const isSearching = !!search
2323
let searchResults: typeof productCodeExamples = []
2424
if (isSearching) {
25-
const matchReg = new RegExp(search, 'i')
25+
// The following replace method escapes special characters in regular expression creation.
26+
const matchReg = new RegExp(search.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'), 'i')
2627
searchResults = productCodeExamples.filter((example) => {
2728
const searchableStr = `${example.tags.join(' ')} ${example.title} ${example.description}`
2829
return matchReg.test(searchableStr)

0 commit comments

Comments
 (0)