diff --git a/src/notifications/ServiceStatusProvider/index.tsx b/src/notifications/ServiceStatusProvider/index.tsx index 064060fc4f..d1bbfd66a2 100644 --- a/src/notifications/ServiceStatusProvider/index.tsx +++ b/src/notifications/ServiceStatusProvider/index.tsx @@ -39,13 +39,17 @@ export function useServiceStatus(): StatusContextType { return useContext(ServiceStatusContext); } +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string +} + export function filterServiceStatusIncidents( incidents: Incident[], tickers: string[] = [] ): Incident[] { if (!tickers || tickers.length === 0) return []; - const tickersRegex = new RegExp(tickers.join("|"), "i"); + const tickersRegex = new RegExp(escapeRegExp(tickers.join("|")), "i"); return incidents.filter( ({ components }) => !components || // dont filter out if no components