Skip to content

Commit fe1478a

Browse files
Merge pull request JavaScriptSolidServer#300 from JavaScriptSolidServer/issue-299-profile-document-predicates
fix: add foaf:isPrimaryTopicOf to WebID profile
2 parents bf8203c + 94e54c5 commit fe1478a

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/webid/profile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const PIM = 'http://www.w3.org/ns/pim/space#';
2424
*/
2525
export function generateProfileJsonLd({ webId, name, podUri, issuer }) {
2626
const pod = podUri.endsWith('/') ? podUri : podUri + '/';
27-
const profileDoc = webId.split('#')[0];
2827

2928
return {
3029
'@context': {
@@ -39,12 +38,14 @@ export function generateProfileJsonLd({ webId, name, podUri, issuer }) {
3938
'preferencesFile': { '@id': 'pim:preferencesFile', '@type': '@id' },
4039
'publicTypeIndex': { '@id': 'solid:publicTypeIndex', '@type': '@id' },
4140
'privateTypeIndex': { '@id': 'solid:privateTypeIndex', '@type': '@id' },
41+
'isPrimaryTopicOf': { '@id': 'foaf:isPrimaryTopicOf', '@type': '@id' },
4242
'mainEntityOfPage': { '@id': 'schema:mainEntityOfPage', '@type': '@id' }
4343
},
4444
'@id': webId,
4545
'@type': ['foaf:Person', 'schema:Person'],
4646
'foaf:name': name,
47-
'mainEntityOfPage': profileDoc,
47+
'isPrimaryTopicOf': '',
48+
'mainEntityOfPage': '',
4849
'inbox': `${pod}inbox/`,
4950
'storage': pod,
5051
'oidcIssuer': issuer,

test/webid.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,20 @@ describe('WebID Profile', () => {
8383
assert.ok(jsonLd['inbox'].endsWith('/webidtest/inbox/'), 'Should have inbox');
8484
});
8585

86-
it('should have mainEntityOfPage', async () => {
86+
it('should have mainEntityOfPage pointing to the document', async () => {
8787
const res = await request(profilePath);
8888
const jsonLd = await res.json();
8989

90-
assert.ok(jsonLd['mainEntityOfPage'], 'Should have mainEntityOfPage');
90+
// Empty string is a relative URI reference to the document itself (JSON-LD)
91+
assert.strictEqual(jsonLd['mainEntityOfPage'], '', 'mainEntityOfPage should be "" (self)');
92+
});
93+
94+
it('should have isPrimaryTopicOf pointing to the document', async () => {
95+
const res = await request(profilePath);
96+
const jsonLd = await res.json();
97+
98+
// Empty string is a relative URI reference to the document itself (JSON-LD)
99+
assert.strictEqual(jsonLd['isPrimaryTopicOf'], '', 'isPrimaryTopicOf should be "" (self)');
91100
});
92101
});
93102

0 commit comments

Comments
 (0)