Skip to content

Commit 01e12b0

Browse files
fix: add foaf:isPrimaryTopicOf to WebID profile
Per the Solid WebID Profile spec, profiles link the agent to the document via foaf:isPrimaryTopicOf. Empty string is a relative URI reference to the document itself. Keeps schema:mainEntityOfPage for schema.org compatibility. Closes JavaScriptSolidServer#299
1 parent bf8203c commit 01e12b0

2 files changed

Lines changed: 13 additions & 3 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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,16 @@ describe('WebID Profile', () => {
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
91+
assert.ok('mainEntityOfPage' in jsonLd, 'Should have mainEntityOfPage');
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
99+
assert.ok('isPrimaryTopicOf' in jsonLd, 'Should have foaf:isPrimaryTopicOf');
91100
});
92101
});
93102

0 commit comments

Comments
 (0)