Skip to content

Commit 2060ba6

Browse files
committed
allow downloading specific version
1 parent ea228a6 commit 2060ba6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

api/download.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ module.exports = (req, res) => {
2121
.then((r) => r.json())
2222
.then((r) => {
2323
const latest = r['dist-tags'].latest;
24-
const link = r.versions[r['dist-tags'].latest].dist.tarball;
24+
const selected = req.query.version || latest;
25+
if (!r.versions[selected]) {
26+
return res.status(404).end('no such version');
27+
}
28+
const link = r.versions[selected].dist.tarball;
2529
return fetch(link, {
2630
redirect: 'manual',
2731
headers: { authorization },
2832
}).then((r2) => {
2933
res.status(200);
3034
return res.json({
3135
latest,
36+
selected,
3237
tarball: r2.headers.get('location'),
3338
});
3439
});

0 commit comments

Comments
 (0)