Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

LL-8545 fix ticker regex issue #1559

Merged
merged 1 commit into from
Dec 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/notifications/ServiceStatusProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down