debug: trace inside buildHref

This commit is contained in:
Semih
2026-05-19 08:54:36 +03:00
parent 4defb0bfea
commit dbdc0d476b

View File

@@ -17,12 +17,18 @@ export function buildHref(
...patch,
} as Record<string, string | string[] | undefined>;
const usp = new URLSearchParams();
const trace: string[] = [];
for (const [k, v] of Object.entries(merged)) {
trace.push(`${k}=${JSON.stringify(v)}(${typeof v})`);
if (v === undefined || v === null || v === "") continue;
if (Array.isArray(v)) for (const item of v) if (item) usp.append(k, item);
else usp.set(k, String(v));
}
const qs = usp.toString();
// eslint-disable-next-line no-console
if (typeof window !== "undefined") {
console.log("[buildHref] entries=", trace.join(" | "), "qs=", qs);
}
return qs ? `?${qs}` : "?";
}