Compare commits

...

1 Commits

Author SHA1 Message Date
Jonathan Gramain 1db5909676 tentative fix for the maxKeys==0 bug + unit test
Issue #250
2017-05-02 12:32:45 -07:00
2 changed files with 13 additions and 3 deletions

View File

@ -55,7 +55,8 @@ class Delimiter extends Extension {
this.delimiter = parameters.delimiter; this.delimiter = parameters.delimiter;
this.prefix = parameters.prefix; this.prefix = parameters.prefix;
this.marker = parameters.marker; this.marker = parameters.marker;
this.maxKeys = parameters.maxKeys || 1000; this.maxKeys = (parameters.maxKeys !== undefined ?
parameters.maxKeys : 1000);
// results // results
this.CommonPrefixes = []; this.CommonPrefixes = [];
this.Contents = []; this.Contents = [];
@ -99,8 +100,8 @@ class Delimiter extends Extension {
*/ */
_reachedMaxKeys() { _reachedMaxKeys() {
if (this.keys >= this.maxKeys) { if (this.keys >= this.maxKeys) {
// In cases of maxKeys <= 0 -> IsTruncated = false // In cases of maxKeys < 0 -> IsTruncated = false
this.IsTruncated = this.maxKeys > 0; this.IsTruncated = this.maxKeys >= 0;
return true; return true;
} }
return false; return false;

View File

@ -123,6 +123,15 @@ const tests = [
IsTruncated: false, IsTruncated: false,
NextMarker: undefined, NextMarker: undefined,
}), }),
new Test('with zero makKeys', {
maxKeys: 0,
}, {
Contents: [],
CommonPrefixes: [],
Delimiter: undefined,
IsTruncated: true,
NextMarker: undefined,
}),
new Test('with delimiter', { new Test('with delimiter', {
delimiter: '/', delimiter: '/',
}, { }, {