fix: (regression beta) admin/plugins/search: error 422 unless entering some text
Massimo Melina committed
May 9, 2024 at 23:59 UTC
1e5080decbd115b258563ac04f01c0696c5ce9d5
1 file changed
+2
-2
src/github.ts
+2
-2
@@ -174,8 +174,8 @@ async function *apiGithubPaginated<T=any>(uri: string) {
174
175
export async function searchPlugins(text='', { skipRepos=[''] }={}) {
176
const projectInfo = await getProjectInfo()
177
- const list = await Promise.all(['', 'user:'].map(specifier => // search text with multiple specifiers
178
- asyncGeneratorToArray(apiGithubPaginated(`search/repositories?q=topic:hfs-plugin+${specifier}${encodeURI(text)}`))))
177
+ const searches = [encodeURI(text), ...text.split(' ').filter(Boolean).slice(0, 2).map(x => 'user:' + encodeURI(x))] // first 2 words can be the author
178
+ const list = await Promise.all(searches.map(x => asyncGeneratorToArray(apiGithubPaginated(`search/repositories?q=topic:hfs-plugin+${x}`))))
179
.then(all => all.flat()) // make it a single array
180
return new AsapStream(list.map(async it => { // using AsapStream we parallelize these promises and produce each result as it's ready
181
const repo = it.full_name as string