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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Fixed

* Fix jsonld validator no longer accepting `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`

## v4.2.0 (2023-01-18)

### Added
Expand Down
2 changes: 1 addition & 1 deletion pub/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
],
formUrlType: 'application/x-www-form-urlencoded',
jsonldTypes: [
'application/ld+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'application/activity+json'
],
// type-is is not able to match this pattern
Expand Down
55 changes: 55 additions & 0 deletions spec/functional/object.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,61 @@ describe('resources', function () {
expect(res.get('content-type')?.includes('application/ld+json')).toBeTrue()
expect(res.body).toEqual(standard)
})
it('handles fully qualified activitypub mime', async function () {
const oid = apex.utils.objectIdToIRI()
let obj = {
id: oid,
type: 'Note',
content: 'Hello.',
attributedTo: 'https://localhost/u/test',
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
}
obj = await apex.fromJSONLD(obj)
await apex.store.saveObject(obj)
const res = await request(app)
.get(oid.replace('https://localhost', ''))
.set('Accept', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"')
.expect(200)
const standard = {
'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'],
id: oid,
type: 'Note',
content: 'Hello.',
attributedTo: 'https://localhost/u/test',
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
}
// don't match the whole string because express injects other params like charset
expect(res.get('content-type').includes('application/ld+json')).toBeTrue()
expect(res.get('content-type').includes('profile="https://www.w3.org/ns/activitystreams"')).toBeTrue()
expect(res.body).toEqual(standard)
})
it('handles fully shorthand activitypub mime', async function () {
const oid = apex.utils.objectIdToIRI()
let obj = {
id: oid,
type: 'Note',
content: 'Hello.',
attributedTo: 'https://localhost/u/test',
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
}
obj = await apex.fromJSONLD(obj)
await apex.store.saveObject(obj)
const res = await request(app)
.get(oid.replace('https://localhost', ''))
.set('Accept', 'application/activity+json')
.expect(200)
const standard = {
'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'],
id: oid,
type: 'Note',
content: 'Hello.',
attributedTo: 'https://localhost/u/test',
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
}
// don't match the whole string because express injects other params like charset
expect(res.get('content-type').includes('application/activity+json')).toBeTrue()
expect(res.body).toEqual(standard)
})
})
describe('get activity', function () {
it('returns public activity', async function () {
Expand Down