Skip to content

Commit 24c5fe9

Browse files
author
vvo
committed
fix(dependedUpon): encode start and en keys
This is to avoid badly formatted requests
1 parent dcebd0b commit 24c5fe9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

npm.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,18 @@ export function getDownloads(pkgs) {
9797

9898
export function getDependents(pkgs) {
9999
return Promise.all(
100-
pkgs.map(({ name }) =>
101-
got(
102-
`${c.npmRegistryEndpoint}/_design/app/_view/dependedUpon?startkey=%5B%22${name}%22%5D&endkey=%5B%22${name}%22%2C%22%EF%BF%B0%22%5D&limit=1&reduce=true&stale=update_after`,
100+
pkgs.map(({ name }) => {
101+
const startKey = JSON.stringify([name]);
102+
const endKey = JSON.stringify([name, {}]);
103+
return got(
104+
`${c.npmRegistryEndpoint}/_design/app/_view/dependedUpon?startkey=${startKey}&endkey=${endKey}&stale=update_after`,
103105
{ json: true }
104106
)
105107
.then(res => res.body.rows[0] || { value: 0 })
106108
.then(({ value }) => ({
107109
dependents: value,
108110
humanDependents: numeral(value).format('0.[0]a'),
109-
}))
110-
)
111+
}));
112+
})
111113
);
112114
}

0 commit comments

Comments
 (0)