Skip to content

Commit 6f4b22b

Browse files
committed
fix: Set target on Container POST
Notification emitted when a resource is created as a result of POST on a container sets the `target` property to the `Location` header, consistent with the requirements of `as:Add`.
1 parent 3fa2be9 commit 6f4b22b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/handlers/notify.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ function handler (req, res, next) {
6060
) {
6161
const mediaType = negotiatedFields['content-type']
6262
const activity = getActivity(method, path)
63+
const target = activity === 'Add'
64+
? res.getHeader('location')
65+
: undefined
6366
if (ALLOWED_RDF_MIME_TYPES.includes(mediaType?.[0])) {
6467
return `${headerTemplate(negotiatedFields)}\r\n${solidRDFTemplate({
6568
activity,
6669
eventID,
6770
object: String(fullUrl),
71+
target,
6872
date: eventDate,
6973
// We use eTag as a proxy for state for now
7074
state: res.getHeader('ETag'),

test/integration/prep-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ solid:inserts { <u> <v> <z>. }.`
144144
expect(notification).to.haveOwnProperty('published')
145145
expect(notification.type).to.equal('Add')
146146
expect(notification.object).to.match(/sampleContainer\/$/)
147+
expect(notification.target).to.match(/sampleContainer\/.*example-prep.ttl$/)
147148
controller.abort()
148149
})
149150
})

0 commit comments

Comments
 (0)