debug: trace inside buildHref
This commit is contained in:
@@ -17,12 +17,18 @@ export function buildHref(
|
|||||||
...patch,
|
...patch,
|
||||||
} as Record<string, string | string[] | undefined>;
|
} as Record<string, string | string[] | undefined>;
|
||||||
const usp = new URLSearchParams();
|
const usp = new URLSearchParams();
|
||||||
|
const trace: string[] = [];
|
||||||
for (const [k, v] of Object.entries(merged)) {
|
for (const [k, v] of Object.entries(merged)) {
|
||||||
|
trace.push(`${k}=${JSON.stringify(v)}(${typeof v})`);
|
||||||
if (v === undefined || v === null || v === "") continue;
|
if (v === undefined || v === null || v === "") continue;
|
||||||
if (Array.isArray(v)) for (const item of v) if (item) usp.append(k, item);
|
if (Array.isArray(v)) for (const item of v) if (item) usp.append(k, item);
|
||||||
else usp.set(k, String(v));
|
else usp.set(k, String(v));
|
||||||
}
|
}
|
||||||
const qs = usp.toString();
|
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}` : "?";
|
return qs ? `?${qs}` : "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user