Skip to content
Browse files

Fixes double encoding issue presented with the 0.8.7 release

  • Loading branch information...
1 parent 35573af commit b5bf86026923744a2416d65744e3482e7a7166f3 @colinmutter colinmutter committed
Showing with 33 additions and 1 deletion.
  1. +3 −1 lib/client.js
  2. +30 −0 test/knox.test.js
View
4 lib/client.js
@@ -815,7 +815,9 @@ Client.prototype.list = function(params, headers, fn){
params = null;
}
- var url = params ? '?' + qs.stringify(params) : '';
+ // Stringify the list params but don't encode them yet, since ::request
+ // already encodes the value, leading to double-encoding issues
+ var url = params ? '?' + decodeURIComponent(qs.stringify(params)) : '';
return this.getFile(url, headers, function(err, res){
if (err) return fn(err);
View
30 test/knox.test.js
@@ -475,6 +475,34 @@ function runTestsForStyle(style, userFriendlyName) {
});
});
});
+
+ it('should list files with a specified prefix with slash', function (done) {
+ var files = ['/list/slash-1.json', '/list/slash-2.json'];
+
+ client.putFile(jsonFixture, files[0], function (err, res) {
+ assert.ifError(err);
+ client.putFile(jsonFixture, files[1], function (err, res) {
+ assert.ifError(err);
+ client.list({ prefix: 'list/slash-' }, function (err, data) {
+ assert.ifError(err);
+
+ assert.strictEqual(data.Prefix, 'list/slash-');
+ assert.strictEqual(data.IsTruncated, false);
+ assert.strictEqual(data.MaxKeys, 1000);
+ assert.strictEqual(data.Contents.length, 2);
+ assert(data.Contents[0].LastModified instanceof Date);
+ assert.strictEqual(typeof data.Contents[0].Size, 'number');
+ assert.deepEqual(
+ Object.keys(data.Contents[0]),
+ ['Key', 'LastModified', 'ETag', 'Size', 'Owner', 'StorageClass']
+ );
+
+ done();
+ });
+ });
+ });
+ });
+
});
describe('request()', function () {
@@ -498,6 +526,8 @@ function runTestsForStyle(style, userFriendlyName) {
'<Object><Key>test/direct-pipe.json</Key></Object>' +
'<Object><Key>list/user1.json</Key></Object>' +
'<Object><Key>list/user2.json</Key></Object>' +
+ '<Object><Key>list/slash-1.json</Key></Object>' +
+ '<Object><Key>list/slash-2.json</Key></Object>' +
'</Delete>';
var req = client.request('POST', '/?delete', {

0 comments on commit b5bf860

Please sign in to comment.
Something went wrong with that request. Please try again.