git ssb

3+

cel / ssb-npm-registry



Commit 0d073639080ba4eb082eaa6bd4fa4bd415ed2525

Fix control flow bug

cel committed on 10/11/2017, 8:38:37 AM
Parent: 78ce860110b5885bd27979420dc921a600384376

Files changed

index.jschanged
index.jsView
@@ -443,9 +443,9 @@
443443 var parts = pathname.split('/')
444444 var pkgName = parts.shift()
445445 if (parts[0] === '-rev') return this.respondError(501, 'Unpublish is not supported')
446446 var spec = parts.shift()
447- try { spec = decodeURIComponent(spec) } finally {}
447+ if (spec) try { spec = decodeURIComponent(spec) } finally {}
448448 if (parts.length > 0) return this.respondError(404)
449449 if (self.req.method === 'PUT') return self.publishPkg(pkgName)
450450 var obj = {
451451 _id: pkgName,
@@ -469,14 +469,13 @@
469469 getMention(null, next)
470470 })
471471 function done(err) {
472472 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)
479478 // get dependency info, for dep(1)
480479 self.getPackageJsonFromTarballBlob(obj.dist.ssbBlobId, function (err, pkg) {
481480 if (err) return self.respondError(500, err.stack || err)
482481 if (pkg) {

Built with git-ssb-web