Commit 0d073639080ba4eb082eaa6bd4fa4bd415ed2525
Fix control flow bug
cel committed on 10/11/2017, 8:38:37 AMParent: 78ce860110b5885bd27979420dc921a600384376
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -443,9 +443,9 @@ | ||
443 | 443 | var parts = pathname.split('/') |
444 | 444 | var pkgName = parts.shift() |
445 | 445 | if (parts[0] === '-rev') return this.respondError(501, 'Unpublish is not supported') |
446 | 446 | var spec = parts.shift() |
447 | - try { spec = decodeURIComponent(spec) } finally {} | |
447 | + if (spec) try { spec = decodeURIComponent(spec) } finally {} | |
448 | 448 | if (parts.length > 0) return this.respondError(404) |
449 | 449 | if (self.req.method === 'PUT') return self.publishPkg(pkgName) |
450 | 450 | var obj = { |
451 | 451 | _id: pkgName, |
@@ -469,14 +469,13 @@ | ||
469 | 469 | getMention(null, next) |
470 | 470 | }) |
471 | 471 | function done(err) { |
472 | 472 | if (err) return self.respondError(500, err.stack || err) |
473 | - if (spec) { | |
474 | - var version = obj['dist-tags'][spec] | |
475 | - || semver.maxSatisfying(Object.keys(obj.versions), spec) | |
476 | - obj = obj.versions[version] | |
477 | - if (!obj) return self.respondError(404, 'version not found: ' + spec) | |
478 | - } | |
473 | + if (!spec) self.respond(200, obj) | |
474 | + var version = obj['dist-tags'][spec] | |
475 | + || semver.maxSatisfying(Object.keys(obj.versions), spec) | |
476 | + obj = obj.versions[version] | |
477 | + if (!obj) return self.respondError(404, 'version not found: ' + spec) | |
479 | 478 | // get dependency info, for dep(1) |
480 | 479 | self.getPackageJsonFromTarballBlob(obj.dist.ssbBlobId, function (err, pkg) { |
481 | 480 | if (err) return self.respondError(500, err.stack || err) |
482 | 481 | if (pkg) { |
Built with git-ssb-web