Skip to content

Commit b8436dc

Browse files
author
Kelvin Luck
committed
fix: Find the precise item we asked for
I guess there is the possibility that we could have retrieved information about a revision with a `Key` which *starts with* the `Prefix` we passed (rather than the entire filename being the prefix we passed). It's pretty easy to guard against this edge case so let's do so...
1 parent 7d615da commit b8436dc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/s3.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ module.exports = CoreObject.extend({
149149
var prefix = options.prefix;
150150
var revisionPrefix = joinUriSegments(prefix, options.filePattern + ":" + options.revisionKey);
151151

152-
return listObjects({ Bucket: bucket, Prefix: revisionPrefix }).then((response) => response.Contents[0]);
152+
return listObjects({ Bucket: bucket, Prefix: revisionPrefix })
153+
.then((response) => response.Contents.find((element) => element.Key === revisionPrefix));
153154
},
154155

155156
fetchRevisions: function(options) {

0 commit comments

Comments
 (0)