All files / src/components/ui viewHref.ts

100% Statements 9/9
100% Branches 8/8
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11      108x 108x 108x 108x 108x 108x    
/** A list view's URL: `path` is the list's own path; `archived` → `?status=archived`,
 *  `unnamed` → `?unnamed=1`, and a non-empty `q` is kept. */
export function viewHref(path: string, view: "all" | "archived" | "unnamed", q: string): string {
  const p = new URLSearchParams();
  if (view === "archived") p.set("status", "archived");
  if (view === "unnamed") p.set("unnamed", "1");
  if (q) p.set("q", q);
  const qs = p.toString();
  return `${path}${qs ? `?${qs}` : ""}`;
}