@@ -98,6 +98,75 @@ describe('WAC Parser', () => {
9898 assert . ok ( auths [ 0 ] . modes . includes ( AccessMode . READ ) ) ;
9999 assert . ok ( auths [ 0 ] . modes . includes ( AccessMode . WRITE ) ) ;
100100 } ) ;
101+
102+ it ( 'should resolve relative accessTo URLs' , async ( ) => {
103+ const acl = {
104+ '@context' : { 'acl' : 'http://www.w3.org/ns/auth/acl#' } ,
105+ '@id' : '#owner' ,
106+ '@type' : 'acl:Authorization' ,
107+ 'acl:agent' : { '@id' : 'https://alice.example/#me' } ,
108+ 'acl:accessTo' : { '@id' : './' } ,
109+ 'acl:mode' : [ { '@id' : 'acl:Read' } ]
110+ } ;
111+
112+ const auths = await parseAcl ( JSON . stringify ( acl ) , 'https://alice.example/folder/.acl' ) ;
113+
114+ assert . strictEqual ( auths . length , 1 ) ;
115+ assert . ok ( auths [ 0 ] . accessTo . includes ( 'https://alice.example/folder/' ) ,
116+ `Expected accessTo to include 'https://alice.example/folder/', got: ${ auths [ 0 ] . accessTo } ` ) ;
117+ } ) ;
118+
119+ it ( 'should resolve relative default URLs' , async ( ) => {
120+ const acl = {
121+ '@context' : { 'acl' : 'http://www.w3.org/ns/auth/acl#' } ,
122+ '@id' : '#owner' ,
123+ '@type' : 'acl:Authorization' ,
124+ 'acl:agent' : { '@id' : 'https://alice.example/#me' } ,
125+ 'acl:accessTo' : { '@id' : './' } ,
126+ 'acl:default' : { '@id' : './' } ,
127+ 'acl:mode' : [ { '@id' : 'acl:Read' } ]
128+ } ;
129+
130+ const auths = await parseAcl ( JSON . stringify ( acl ) , 'https://alice.example/folder/.acl' ) ;
131+
132+ assert . strictEqual ( auths . length , 1 ) ;
133+ assert . ok ( auths [ 0 ] . default . includes ( 'https://alice.example/folder/' ) ,
134+ `Expected default to include 'https://alice.example/folder/', got: ${ auths [ 0 ] . default } ` ) ;
135+ } ) ;
136+
137+ it ( 'should resolve parent-relative URLs like ../other/' , async ( ) => {
138+ const acl = {
139+ '@context' : { 'acl' : 'http://www.w3.org/ns/auth/acl#' } ,
140+ '@id' : '#owner' ,
141+ '@type' : 'acl:Authorization' ,
142+ 'acl:agent' : { '@id' : 'https://alice.example/#me' } ,
143+ 'acl:accessTo' : { '@id' : '../other/' } ,
144+ 'acl:mode' : [ { '@id' : 'acl:Read' } ]
145+ } ;
146+
147+ const auths = await parseAcl ( JSON . stringify ( acl ) , 'https://alice.example/folder/.acl' ) ;
148+
149+ assert . strictEqual ( auths . length , 1 ) ;
150+ assert . ok ( auths [ 0 ] . accessTo . includes ( 'https://alice.example/other/' ) ,
151+ `Expected accessTo to include 'https://alice.example/other/', got: ${ auths [ 0 ] . accessTo } ` ) ;
152+ } ) ;
153+
154+ it ( 'should keep absolute URLs unchanged' , async ( ) => {
155+ const acl = {
156+ '@context' : { 'acl' : 'http://www.w3.org/ns/auth/acl#' } ,
157+ '@id' : '#owner' ,
158+ '@type' : 'acl:Authorization' ,
159+ 'acl:agent' : { '@id' : 'https://alice.example/#me' } ,
160+ 'acl:accessTo' : { '@id' : 'https://other.example/resource' } ,
161+ 'acl:mode' : [ { '@id' : 'acl:Read' } ]
162+ } ;
163+
164+ const auths = await parseAcl ( JSON . stringify ( acl ) , 'https://alice.example/folder/.acl' ) ;
165+
166+ assert . strictEqual ( auths . length , 1 ) ;
167+ assert . ok ( auths [ 0 ] . accessTo . includes ( 'https://other.example/resource' ) ,
168+ `Expected accessTo to include 'https://other.example/resource', got: ${ auths [ 0 ] . accessTo } ` ) ;
169+ } ) ;
101170 } ) ;
102171
103172 describe ( 'generateOwnerAcl' , ( ) => {
0 commit comments