Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/storage/object/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
status: resp.$metadata.httpStatusCode,
contentType: resp.ContentType,
contentLength: resp.ContentLength,
metadata: resp.Metadata,
metadata: {
...resp.Metadata,
LastModified: resp.LastModified,
},

Check warning on line 42 in src/storage/object/get.js

View check run for this annotation

Codecov / codecov/patch

src/storage/object/get.js#L39-L42

Added lines #L39 - L42 were not covered by tests
etag: resp.ETag,
};
} catch (e) {
Expand All @@ -56,7 +59,10 @@
status: resp.status,
contentType: resp.headers.get('content-type'),
contentLength: resp.headers.get('content-length'),
metadata: Metadata,
metadata: {
...resp.Metadata,
LastModified: resp.headers.get('last-modified'),
},

Check warning on line 65 in src/storage/object/get.js

View check run for this annotation

Codecov / codecov/patch

src/storage/object/get.js#L62-L65

Added lines #L62 - L65 were not covered by tests
etag: resp.headers.get('etag'),
};
}
4 changes: 2 additions & 2 deletions src/utils/daResp.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default function daResp({
headers.append('X-da-id', metadata.id);
}

if (metadata?.timestamp) {
headers.append('Last-Modified', new Date(parseInt(metadata.timestamp, 10)).toUTCString());
if (metadata?.LastModified) {
headers.append('Last-Modified', new Date(metadata.LastModified).toUTCString());
}

if (ctx?.aclCtx && status < 500) {
Expand Down
2 changes: 1 addition & 1 deletion test/utils/daResp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('DA Resp', () => {
const aclCtx = { actionSet: ['read', 'write'], pathLookup: new Map() };
const ctx = { key: 'foo/bar.html', aclCtx };
const body = 'foobar';
const metadata = { id: '1234', timestamp: '1719235200000' };
const metadata = { id: '1234', LastModified: '2024-06-24T13:20:00.000Z' };

const resp = daResp({status: 200, body, contentType: 'text/plain', contentLength: 777, metadata}, ctx);
assert.strictEqual(body, await resp.text());
Expand Down