File tree Expand file tree Collapse file tree
packages/fedify/src/vocab Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1333,6 +1333,34 @@ for (const typeUri in types) {
13331333 ) ;
13341334 } ) ;
13351335
1336+ test ( "Person.fromJsonLd() with relative URLs and baseUrl" , async ( ) => {
1337+ const json = {
1338+ "@context" : [
1339+ "https://www.w3.org/ns/activitystreams" ,
1340+ "https://w3id.org/security/v1" ,
1341+ ] ,
1342+ "id" :
1343+ "https://hackers.pub/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c" ,
1344+ "type" : "Person" ,
1345+ "name" : "Test User" ,
1346+ "icon" : {
1347+ "type" : "Image" ,
1348+ "url" : "/avatars/test-avatar.jpg" ,
1349+ } ,
1350+ } ;
1351+
1352+ const personWithBase = await Person . fromJsonLd ( json , {
1353+ baseUrl : new URL ( "https://example.com" ) ,
1354+ } ) ;
1355+
1356+ const icon = await personWithBase . getIcon ( ) ;
1357+ assertEquals (
1358+ icon ?. url ,
1359+ new URL ( "https://example.com/avatars/test-avatar.jpg" ) ,
1360+ ) ;
1361+ assertEquals ( personWithBase . baseUrl , new URL ( "https://example.com" ) ) ;
1362+ } ) ;
1363+
13361364 if ( "Deno" in globalThis ) {
13371365 const { assertSnapshot } = await import ( "@std/testing/snapshot" ) . catch (
13381366 ( ) => ( { assertSnapshot : ( ) => Promise . resolve ( ) } ) ,
You can’t perform that action at this time.
0 commit comments