Comparing version 1.8.0 to 1.9.0
37
aws4.js
@@ -223,3 +223,3 @@ var aws4 = exports, | ||
if (query) { | ||
queryStr = encodeRfc3986(querystring.stringify(Object.keys(query).sort().reduce(function(obj, key) { | ||
var reducedQuery = Object.keys(query).reduce(function(obj, key) { | ||
if (!key) return obj | ||
@@ -229,3 +229,13 @@ obj[key] = !Array.isArray(query[key]) ? query[key] : | ||
return obj | ||
}, {}))) | ||
}, {}) | ||
var encodedQueryPieces = [] | ||
Object.keys(reducedQuery).forEach(function(key) { | ||
var encodedPrefix = encodeURIComponent(key) + '=' | ||
if (!Array.isArray(reducedQuery[key])) { | ||
encodedQueryPieces.push(encodeRfc3986(encodedPrefix + encodeURIComponent(reducedQuery[key]))) | ||
} else { | ||
reducedQuery[key].forEach(function(val) { encodedQueryPieces.push(encodeRfc3986(encodedPrefix + encodeURIComponent(val))) }) | ||
} | ||
}) | ||
queryStr = encodedQueryPieces.sort().join('&') | ||
} | ||
@@ -238,3 +248,3 @@ if (pathStr !== '/') { | ||
} else if (!normalizePath || piece !== '.') { | ||
if (decodePath) piece = decodeURIComponent(piece) | ||
if (decodePath) piece = decodeURIComponent(piece).replace(/\+/g, ' ') | ||
path.push(encodeRfc3986(encodeURIComponent(piece))) | ||
@@ -295,4 +305,12 @@ } | ||
RequestSigner.prototype.parsePath = function() { | ||
var path = this.request.path || '/', | ||
queryIx = path.indexOf('?'), | ||
var path = this.request.path || '/' | ||
// S3 doesn't always encode characters > 127 correctly and | ||
// all services don't encode characters > 255 correctly | ||
// So if there are non-reserved chars (and it's not already all % encoded), just encode them all | ||
if (/[^0-9A-Za-z;,/?:@&=+$\-_.!~*'()#%]/.test(path)) { | ||
path = encodeURI(decodeURI(path)) | ||
} | ||
var queryIx = path.indexOf('?'), | ||
query = null | ||
@@ -305,11 +323,2 @@ | ||
// S3 doesn't always encode characters > 127 correctly and | ||
// all services don't encode characters > 255 correctly | ||
// So if there are non-reserved chars (and it's not already all % encoded), just encode them all | ||
if (/[^0-9A-Za-z!'()*\-._~%/]/.test(path)) { | ||
path = path.split('/').map(function(piece) { | ||
return encodeURIComponent(decodeURIComponent(piece)) | ||
}).join('/') | ||
} | ||
this.parsedPath = { | ||
@@ -316,0 +325,0 @@ path: path, |
{ | ||
"name": "aws4", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Signs and prepares requests using AWS Signature Version 4", | ||
@@ -69,4 +69,4 @@ "author": "Michael Hart <michael.hart.au@gmail.com> (http://github.com/mhart)", | ||
"scripts": { | ||
"test": "mocha ./test/fast.js ./test/slow.js -b -t 100s -R list" | ||
"test": "mocha ./test/fast.js -b -t 100s -R list" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32351
357