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
5 changes: 3 additions & 2 deletions src/webid/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const PIM = 'http://www.w3.org/ns/pim/space#';
*/
export function generateProfileJsonLd({ webId, name, podUri, issuer }) {
const pod = podUri.endsWith('/') ? podUri : podUri + '/';
const profileDoc = webId.split('#')[0];

return {
'@context': {
Expand All @@ -39,12 +38,14 @@ export function generateProfileJsonLd({ webId, name, podUri, issuer }) {
'preferencesFile': { '@id': 'pim:preferencesFile', '@type': '@id' },
'publicTypeIndex': { '@id': 'solid:publicTypeIndex', '@type': '@id' },
'privateTypeIndex': { '@id': 'solid:privateTypeIndex', '@type': '@id' },
'isPrimaryTopicOf': { '@id': 'foaf:isPrimaryTopicOf', '@type': '@id' },
'mainEntityOfPage': { '@id': 'schema:mainEntityOfPage', '@type': '@id' }
},
'@id': webId,
'@type': ['foaf:Person', 'schema:Person'],
'foaf:name': name,
'mainEntityOfPage': profileDoc,
'isPrimaryTopicOf': '',
'mainEntityOfPage': '',
Comment on lines 44 to +48

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds foaf:isPrimaryTopicOf on the #me node, but it still does not describe the profile document itself (e.g., <> a foaf:PersonalProfileDocument; foaf:primaryTopic <#me>; foaf:maker <#me>). If this PR is intended to close #299 and support clients that discover a user by dereferencing the document URL and following foaf:primaryTopic, the profile generator likely needs to emit a document node (typically via @graph) in addition to foaf:isPrimaryTopicOf.

Copilot uses AI. Check for mistakes.
'inbox': `${pod}inbox/`,
Comment on lines 46 to 49

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainEntityOfPage was changed from an absolute document IRI to an empty string. While "" can resolve to the document IRI in JSON-LD when a base IRI is provided, many schema.org-oriented consumers treat this value as a plain string and may not resolve relative IRIs, which would be a behavior change/regression versus the previous absolute URL. Consider restoring the absolute document URL for mainEntityOfPage (or explicitly setting @base in the JSON-LD context so relative IRIs are unambiguous) while keeping foaf:isPrimaryTopicOf as needed.

Copilot uses AI. Check for mistakes.
'storage': pod,
'oidcIssuer': issuer,
Expand Down
13 changes: 11 additions & 2 deletions test/webid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,20 @@ describe('WebID Profile', () => {
assert.ok(jsonLd['inbox'].endsWith('/webidtest/inbox/'), 'Should have inbox');
});

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

assert.ok(jsonLd['mainEntityOfPage'], 'Should have mainEntityOfPage');
// Empty string is a relative URI reference to the document itself (JSON-LD)
assert.strictEqual(jsonLd['mainEntityOfPage'], '', 'mainEntityOfPage should be "" (self)');
});

it('should have isPrimaryTopicOf pointing to the document', async () => {
const res = await request(profilePath);
const jsonLd = await res.json();

// Empty string is a relative URI reference to the document itself (JSON-LD)
assert.strictEqual(jsonLd['isPrimaryTopicOf'], '', 'isPrimaryTopicOf should be "" (self)');
});
Comment on lines +86 to 100

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests assert an exact empty-string value for mainEntityOfPage/isPrimaryTopicOf, which tightly couples the tests to a specific JSON-LD serialization choice. If the implementation is adjusted to emit an explicit document IRI (or a different relative form) for compatibility, these tests will fail even though the RDF meaning is unchanged; consider asserting that the fields are present and point to the profile document (e.g., accept "" or the expected absolute URL).

Copilot uses AI. Check for mistakes.
});

Expand Down