Skip to content

Commit 21c54ed

Browse files
authored
Merge pull request #83 from immers-space/82-mime-regression
fix regression in mime type handling close #82
2 parents e9fbbea + 4451293 commit 21c54ed

3 files changed

Lines changed: 62 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
### Fixed
4+
5+
* Fix jsonld validator no longer accepting `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
6+
17
## v4.2.0 (2023-01-18)
28

39
### Added

pub/consts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
],
66
formUrlType: 'application/x-www-form-urlencoded',
77
jsonldTypes: [
8-
'application/ld+json',
8+
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
99
'application/activity+json'
1010
],
1111
// type-is is not able to match this pattern

spec/functional/object.spec.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,61 @@ describe('resources', function () {
135135
expect(res.get('content-type')?.includes('application/ld+json')).toBeTrue()
136136
expect(res.body).toEqual(standard)
137137
})
138+
it('handles fully qualified activitypub mime', async function () {
139+
const oid = apex.utils.objectIdToIRI()
140+
let obj = {
141+
id: oid,
142+
type: 'Note',
143+
content: 'Hello.',
144+
attributedTo: 'https://localhost/u/test',
145+
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
146+
}
147+
obj = await apex.fromJSONLD(obj)
148+
await apex.store.saveObject(obj)
149+
const res = await request(app)
150+
.get(oid.replace('https://localhost', ''))
151+
.set('Accept', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"')
152+
.expect(200)
153+
const standard = {
154+
'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'],
155+
id: oid,
156+
type: 'Note',
157+
content: 'Hello.',
158+
attributedTo: 'https://localhost/u/test',
159+
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
160+
}
161+
// don't match the whole string because express injects other params like charset
162+
expect(res.get('content-type').includes('application/ld+json')).toBeTrue()
163+
expect(res.get('content-type').includes('profile="https://www.w3.org/ns/activitystreams"')).toBeTrue()
164+
expect(res.body).toEqual(standard)
165+
})
166+
it('handles fully shorthand activitypub mime', async function () {
167+
const oid = apex.utils.objectIdToIRI()
168+
let obj = {
169+
id: oid,
170+
type: 'Note',
171+
content: 'Hello.',
172+
attributedTo: 'https://localhost/u/test',
173+
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
174+
}
175+
obj = await apex.fromJSONLD(obj)
176+
await apex.store.saveObject(obj)
177+
const res = await request(app)
178+
.get(oid.replace('https://localhost', ''))
179+
.set('Accept', 'application/activity+json')
180+
.expect(200)
181+
const standard = {
182+
'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'],
183+
id: oid,
184+
type: 'Note',
185+
content: 'Hello.',
186+
attributedTo: 'https://localhost/u/test',
187+
to: ['https://ignore.com/u/ignored', apex.consts.publicAddress]
188+
}
189+
// don't match the whole string because express injects other params like charset
190+
expect(res.get('content-type').includes('application/activity+json')).toBeTrue()
191+
expect(res.body).toEqual(standard)
192+
})
138193
})
139194
describe('get activity', function () {
140195
it('returns public activity', async function () {

0 commit comments

Comments
 (0)