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/wac/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ function parseAuthorization(node, aclUrl) {
auth.default = parseUriArray(node['acl:default'] || node['default'])
.map(uri => resolveUri(uri, baseUrl));

// Parse agents (WebIDs can be relative too)
auth.agents = parseUriArray(node['acl:agent'] || node['agent']);
// Parse agents (WebIDs can be relative too) - resolve against ACL URL
auth.agents = parseUriArray(node['acl:agent'] || node['agent'])
.map(uri => resolveUri(uri, aclUrl));
Comment on lines +148 to +149
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

This change adds support for resolving relative agent URIs, but there's no test coverage for this new behavior. Consider adding a test case similar to the existing tests for relative accessTo and default URLs (lines 138-171) that verifies relative agent URIs like './#me' are properly resolved against the ACL URL.

Copilot uses AI. Check for mistakes.

// Parse agentClass
auth.agentClasses = parseUriArray(node['acl:agentClass'] || node['agentClass']);
Expand Down
17 changes: 17 additions & 0 deletions test/wac.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,23 @@ describe('WAC Parser', () => {
`Expected accessTo to include 'https://alice.example/other/', got: ${auths[0].accessTo}`);
});

it('should resolve relative agent URIs against ACL URL', async () => {
const acl = {
'@context': { 'acl': 'http://www.w3.org/ns/auth/acl#' },
'@id': '#owner',
'@type': 'acl:Authorization',
'acl:agent': { '@id': './#me' },
'acl:accessTo': { '@id': './' },
'acl:mode': [{ '@id': 'acl:Read' }]
};

const auths = await parseAcl(JSON.stringify(acl), 'https://alice.example/.acl');

assert.strictEqual(auths.length, 1);
assert.ok(auths[0].agents.includes('https://alice.example/#me'),
`Expected agents to include 'https://alice.example/#me', got: ${auths[0].agents}`);
});

it('should keep absolute URLs unchanged', async () => {
const acl = {
'@context': { 'acl': 'http://www.w3.org/ns/auth/acl#' },
Expand Down