Skip to content

Commit 550154a

Browse files
committed
Made the search params code more robust
1 parent 004e703 commit 550154a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

apps/webapp/app/components/runs/v3/TaskRunsTable.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ export function TaskRunsTable({
9191
const { isManagedCloud } = useFeatures();
9292
const { value } = useSearchParams();
9393
const location = useOptimisticLocation();
94-
const rootOnly = value("rootOnly") ? `` : `rootOnly=${rootOnlyDefault}`;
95-
let search = rootOnly ? `${rootOnly}&${location.search}` : location.search;
94+
const params = new URLSearchParams(location.search || "");
95+
if (!value("rootOnly")) {
96+
params.set("rootOnly", String(rootOnlyDefault));
97+
}
9698
if (additionalTableState) {
97-
const params = new URLSearchParams(search);
9899
for (const [key, val] of Object.entries(additionalTableState)) {
99100
params.set(key, val);
100101
}
101-
search = params.toString();
102102
}
103+
const search = params.toString();
103104
/** TableState has to be encoded as a separate URI component, so it's merged under one, 'tableState' param */
104105
const tableStateParam = disableAdjacentRows ? '' : encodeURIComponent(search);
105106

0 commit comments

Comments
 (0)