Skip to content

Commit 1a2af3b

Browse files
committed
fix(web): bound pull request label params
1 parent e5c191c commit 1a2af3b

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎apps/web/src/routes/_chat.pull-requests.tsx‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,17 @@ const EMPTY_PREVIEW_DESKTOP_STATE = {};
205205
const EMPTY_TERMINAL_LABELS = new Map<string, string>();
206206
const EMPTY_PENDING_SURFACES = new Set<string>();
207207

208-
function pullRequestSearchLabels(raw: unknown): ReadonlyArray<string> | undefined {
209-
const values = Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : [];
208+
function pullRequestSearchLabels(raw: unknown): Partial<Pick<PullRequestsSearch, "labels">> {
209+
const values = (Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : []).slice(0, 10);
210210
const labels = values
211211
.filter((value): value is string => typeof value === "string")
212212
.map((value) => value.trim().slice(0, 200))
213213
.filter(
214214
(value, index, all) =>
215215
value.length > 0 &&
216216
all.findIndex((candidate) => candidate.toLowerCase() === value.toLowerCase()) === index,
217-
)
218-
.slice(0, 10);
219-
return labels.length === 0 ? undefined : labels;
217+
);
218+
return labels.length === 0 ? {} : { labels };
220219
}
221220

222221
export const Route = createFileRoute("/_chat/pull-requests")({
@@ -259,9 +258,7 @@ export const Route = createFileRoute("/_chat/pull-requests")({
259258
...(typeof raw.author === "string" && raw.author.trim()
260259
? { author: raw.author.trim().slice(0, 200) }
261260
: {}),
262-
...(pullRequestSearchLabels(raw.labels) === undefined
263-
? {}
264-
: { labels: pullRequestSearchLabels(raw.labels)! }),
261+
...pullRequestSearchLabels(raw.labels),
265262
}),
266263
component: PullRequestsRouteView,
267264
});

0 commit comments

Comments
 (0)