mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-11 02:15:57 -05:00
various bugfixes, camelcase for http headers
This commit is contained in:
parent
bbb402f762
commit
7f7c056ecd
2 changed files with 13 additions and 12 deletions
|
@ -67,6 +67,14 @@ Storage.prototype.add_package = function(name, metadata, callback) {
|
||||||
// something weird
|
// something weird
|
||||||
if (err && err.status !== 404) return cb(err)
|
if (err && err.status !== 404) return cb(err)
|
||||||
|
|
||||||
|
// checking package
|
||||||
|
if (results) {
|
||||||
|
return cb(new UError({
|
||||||
|
status: 409,
|
||||||
|
msg: 'this package is already present'
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
for (var i=0; i<err_results.length; i++) {
|
for (var i=0; i<err_results.length; i++) {
|
||||||
// checking error
|
// checking error
|
||||||
// if uplink fails with a status other than 404, we report failure
|
// if uplink fails with a status other than 404, we report failure
|
||||||
|
@ -80,14 +88,6 @@ Storage.prototype.add_package = function(name, metadata, callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// checking package
|
|
||||||
if (results) {
|
|
||||||
return cb(new UError({
|
|
||||||
status: 409,
|
|
||||||
msg: 'this package is already present'
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
return cb()
|
return cb()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -473,6 +473,7 @@ Storage.prototype.get_package = function(name, options, callback) {
|
||||||
for (var i in result['dist-tags']) {
|
for (var i in result['dist-tags']) {
|
||||||
if (Array.isArray(result['dist-tags'][i])) {
|
if (Array.isArray(result['dist-tags'][i])) {
|
||||||
result['dist-tags'][i] = result['dist-tags'][i][result['dist-tags'][i].length-1]
|
result['dist-tags'][i] = result['dist-tags'][i][result['dist-tags'][i].length-1]
|
||||||
|
if (result['dist-tags'][i] == null) delete result['dist-tags'][i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@ function _setupProxy(hostname, config, mainconfig, isHTTPS) {
|
||||||
Storage.prototype.request = function(options, cb) {
|
Storage.prototype.request = function(options, cb) {
|
||||||
var self = this
|
var self = this
|
||||||
, headers = options.headers || {}
|
, headers = options.headers || {}
|
||||||
headers.accept = headers.accept || 'application/json'
|
headers.Accept = headers.Accept || 'application/json'
|
||||||
headers['user-agent'] = headers['user-agent'] || this.userAgent
|
headers['User-Agent'] = headers['User-Agent'] || this.userAgent
|
||||||
|
|
||||||
var method = options.method || 'GET'
|
var method = options.method || 'GET'
|
||||||
, uri = options.uri_full || (this.config.url + options.uri)
|
, uri = options.uri_full || (this.config.url + options.uri)
|
||||||
|
@ -98,7 +98,7 @@ Storage.prototype.request = function(options, cb) {
|
||||||
|
|
||||||
if (utils.is_object(options.json)) {
|
if (utils.is_object(options.json)) {
|
||||||
var json = JSON.stringify(options.json)
|
var json = JSON.stringify(options.json)
|
||||||
headers['content-type'] = headers['content-type'] || 'application/json'
|
headers['Content-Type'] = headers['Content-Type'] || 'application/json'
|
||||||
}
|
}
|
||||||
|
|
||||||
var req = request({
|
var req = request({
|
||||||
|
@ -224,7 +224,7 @@ Storage.prototype.add_tarball = function(name, filename, options) {
|
||||||
uri: '/' + escape(name) + '/-/' + escape(filename) + '/whatever',
|
uri: '/' + escape(name) + '/-/' + escape(filename) + '/whatever',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/octet-stream'
|
'Content-Type': 'application/octet-stream'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue