Skip to content

Commit

Permalink
add validation to url mode
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Tackett <tackadam@amazon.com>
  • Loading branch information
Adam Tackett committed Jan 8, 2025
1 parent 4ee5670 commit 1b5ab44
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions public/components/trace_analytics/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export const Home = (props: HomeProps) => {
]);
};

const isValidTraceAnalyticsMode = (urlMode: string | null): urlMode is TraceAnalyticsMode => {
return ['jaeger', 'data_prepper', 'custom_data_prepper'].includes(urlMode || '');
};

useEffect(() => {
handleDataPrepperIndicesExistRequest(
props.http,
Expand Down Expand Up @@ -406,7 +410,8 @@ export const Home = (props: HomeProps) => {
render={(_routerProps) => {
const queryParams = new URLSearchParams(window.location.href.split('?')[1]);
const traceId = queryParams.get('traceId');
const traceMode = queryParams.get('mode');
const traceModeFromURL = queryParams.get('mode');
const traceMode = isValidTraceAnalyticsMode(traceModeFromURL) ? traceModeFromURL : mode;

const SideBarComponent = !isNavGroupEnabled ? TraceSideBar : React.Fragment;
if (!traceId) {
Expand Down Expand Up @@ -451,7 +456,10 @@ export const Home = (props: HomeProps) => {
render={(_routerProps) => {
const queryParams = new URLSearchParams(window.location.href.split('?')[1]);
const serviceId = queryParams.get('serviceId');
const serviceMode = queryParams.get('mode');
const serviceModeFromURL = queryParams.get('mode');
const serviceMode = isValidTraceAnalyticsMode(serviceModeFromURL)
? serviceModeFromURL
: mode;

const SideBarComponent = !isNavGroupEnabled ? TraceSideBar : React.Fragment;
if (!serviceId) {
Expand Down

0 comments on commit 1b5ab44

Please sign in to comment.