diff options
Diffstat (limited to 'node_modules/aws4/aws4.js')
-rw-r--r-- | node_modules/aws4/aws4.js | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/node_modules/aws4/aws4.js b/node_modules/aws4/aws4.js index 9014894..ed282f8 100644 --- a/node_modules/aws4/aws4.js +++ b/node_modules/aws4/aws4.js @@ -33,7 +33,7 @@ function RequestSigner(request, credentials) { if (typeof request === 'string') request = url.parse(request) var headers = request.headers = (request.headers || {}), - hostParts = this.matchHost(request.hostname || request.host || headers.Host || headers.host) + hostParts = (!this.service || !this.region) && this.matchHost(request.hostname || request.host || headers.Host || headers.host) this.request = request this.credentials = credentials || this.defaultCredentials() @@ -70,6 +70,19 @@ RequestSigner.prototype.matchHost = function(host) { if (hostParts[1] === 'es') hostParts = hostParts.reverse() + if (hostParts[1] == 's3') { + hostParts[0] = 's3' + hostParts[1] = 'us-east-1' + } else { + for (var i = 0; i < 2; i++) { + if (/^s3-/.test(hostParts[i])) { + hostParts[1] = hostParts[i].slice(3) + hostParts[0] = 's3' + break + } + } + } + return hostParts } @@ -83,10 +96,9 @@ RequestSigner.prototype.isSingleRegion = function() { } RequestSigner.prototype.createHost = function() { - var region = this.isSingleRegion() ? '' : - (this.service === 's3' && this.region !== 'us-east-1' ? '-' : '.') + this.region, - service = this.service === 'ses' ? 'email' : this.service - return service + region + '.amazonaws.com' + var region = this.isSingleRegion() ? '' : '.' + this.region, + subdomain = this.service === 'ses' ? 'email' : this.service + return subdomain + region + '.amazonaws.com' } RequestSigner.prototype.prepareRequest = function() { |