Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rest/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}/${
Expand Down
9 changes: 4 additions & 5 deletions rest/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
};
Expand Down
11 changes: 5 additions & 6 deletions rest/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down