Skip to content

Commit a141ea1

Browse files
committed
constant added for escaped characters
1 parent fe4eacb commit a141ea1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/components/common/helpers/Helpers.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { SIDEBAR_KEYS } from '../../ResourceBrowser/Constants'
1919
import { DEFAULT_SECRET_PLACEHOLDER } from '../../cluster/cluster.type'
2020
import { AUTO_SELECT } from '../../ClusterNodes/constants'
2121
import { ToastBody3 as UpdateToast } from '../ToastBody'
22+
import { PATTERNS } from '../../../config/constants'
2223

2324
export type IntersectionChangeHandler = (entry: IntersectionObserverEntry) => void
2425

@@ -1015,7 +1016,7 @@ export const highlightSearchedText = (searchText: string, matchString: string):
10151016
}
10161017
try {
10171018
const highlightText = (highlighted) => `<mark>${highlighted}</mark>`
1018-
const escapedSearchText = searchText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') // Escape special characters handling
1019+
const escapedSearchText = searchText.replace(PATTERNS.ESCAPED_CHARACTERS, '\\$&') // Escape special characters handling
10191020
const regex = new RegExp(escapedSearchText, 'gi')
10201021
return matchString.replace(regex, highlightText)
10211022
} catch (err) {

src/config/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ export const PATTERNS = {
291291
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
292292
CUSTOM_TAG: /^(?![.-])([a-zA-Z0-9_.-]*\{[Xx]\}[a-zA-Z0-9_.-]*)(?<![.-])$/, //Allowed: Alphanumeric characters, including (_) (.) (-) {x} {X} but cannot begin or end with (.) or (-)
293293
ALPHANUMERIC_WITH_SPECIAL_CHAR_AND_SLASH: /^[A-Za-z0-9._/-]+$/, // allow alphanumeric,(.) ,(-),(_),(/)
294+
ESCAPED_CHARACTERS: /[.*+?^${}()|[\]\\]/g,
294295
}
295296

296297
export const TriggerType = {

0 commit comments

Comments
 (0)