diff --git a/rest/pages.ts b/rest/pages.ts index bed3211..bd757fd 100644 --- a/rest/pages.ts +++ b/rest/pages.ts @@ -39,11 +39,11 @@ const getPage_toRequest: GetPage["toRequest"] = ( options, ) => { const { sid, hostName, followRename, projects } = setDefaults(options ?? {}); - const params = new URLSearchParams(); - params.append("followRename", `${followRename ?? true}`); - for (const id of projects ?? []) { - params.append("projects", id); - } + + const params = new URLSearchParams([ + ["followRename", `${followRename ?? true}`], + ...(projects?.map?.((id) => ["projects", id]) ?? []), + ]); return new Request( `https://${hostName}/api/pages/${project}/${ diff --git a/rest/project.ts b/rest/project.ts index b749019..c352d02 100644 --- a/rest/project.ts +++ b/rest/project.ts @@ -130,13 +130,12 @@ export type ListProjectsError = NotLoggedInError | HTTPError; const ListProject_toRequest: ListProjects["toRequest"] = (projectIds, init) => { const { sid, hostName } = setDefaults(init ?? {}); - const param = new URLSearchParams(); - for (const id of projectIds) { - param.append("ids", id); - } + const params = new URLSearchParams( + projectIds.map((id) => ["ids", id]), + ); return new Request( - `https://${hostName}/api/projects?${param.toString()}`, + `https://${hostName}/api/projects?${params}`, sid ? { headers: { Cookie: cookie(sid) } } : undefined, ); }; diff --git a/rest/search.ts b/rest/search.ts index 45d8dbb..03c4ffc 100644 --- a/rest/search.ts +++ b/rest/search.ts @@ -132,14 +132,13 @@ export const searchForWatchList = async ( > => { const { sid, hostName, fetch } = setDefaults(init ?? {}); - const params = new URLSearchParams(); - params.append("q", encodeURIComponent(query)); - for (const projectId of projectIds) { - params.append("ids", projectId); - } + const params = new URLSearchParams([ + ["q", encodeURIComponent(query)], + ...projectIds.map((projectId) => ["ids", projectId]), + ]); const req = new Request( - `https://${hostName}/api/projects/search/watch-list?${params.toString()}`, + `https://${hostName}/api/projects/search/watch-list?${params}`, sid ? { headers: { Cookie: cookie(sid) } } : undefined, );