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

View File

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