refactor/code-splitting #31

Merged
ilia merged 32 commits from refactor/code-splitting into main 2026-04-08 06:34:20 +00:00
Showing only changes of commit bc4ab58644 - Show all commits

View File

@@ -7,7 +7,7 @@
* @example
* ```ts
* buildQueryString({ category: 'serif', subsets: ['latin', 'latin-ext'] })
* // Returns: "?category=serif&subsets=latin%2Clatin-ext"
* // Returns: "?category=serif&subsets=latin&subsets=latin-ext"
*
* buildQueryString({ limit: 50, page: 1 })
* // Returns: "?limit=50&page=1"
@@ -16,7 +16,7 @@
* // Returns: ""
*
* buildQueryString({ search: 'hello world', active: true })
* // Returns: "?search=hello%20world&active=true"
* // Returns: "?search=hello+world&active=true"
* ```
*/
@@ -35,7 +35,7 @@ export type QueryParams = Record<string, QueryParamValue | undefined | null>;
*
* Handles:
* - Primitive values (string, number, boolean) - converted to strings
* - Arrays - comma-separated values
* - Arrays - multiple parameters with same key (e.g., ?key=1&key=2&key=3)
* - null/undefined - omitted from output
* - Special characters - URL encoded
*
@@ -51,14 +51,12 @@ export function buildQueryString(params: QueryParams): string {
continue;
}
// Handle arrays (comma-separated values)
// Handle arrays - append each item as separate parameter with same key
if (Array.isArray(value)) {
const joined = value
.filter(item => item !== undefined && item !== null)
.map(String)
.join(',');
if (joined) {
searchParams.append(key, joined);
for (const item of value) {
if (item !== undefined && item !== null) {
searchParams.append(key, String(item));
}
}
} else {
// Handle primitives