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

Commit

Permalink
(filterServiceStatusIncidents): fix issue in regex for some cases of …
Browse files Browse the repository at this point in the history
…tickers breaking the filter (#1559)
  • Loading branch information
LFBarreto authored Dec 6, 2021
1 parent f615fdf commit 8d4600d
Showing 1 changed file with 5 additions and 1 deletion.
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

1 comment on commit 8d4600d

@vercel
Copy link

@vercel vercel bot commented on 8d4600d Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.