debug: trace inside buildHref
This commit is contained in:
@@ -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}` : "?";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user