Changeset c49808e in Klonkt
- Timestamp:
- 08/08/2026 11:04:29 PM (4 weeks ago)
- Branches:
- main
- Children:
- c72e45e
- Parents:
- cae7bfc
- git-author:
- Robin <roboburr@…> (08/08/2026 11:04:09 PM)
- git-committer:
- Robin <roboburr@…> (08/08/2026 11:04:29 PM)
- Files:
-
- 2 edited
-
src/services/ActivityPubService.js (modified) (1 diff)
-
test/own-card.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
rcae7bfc rc49808e 1312 1312 const icon = doc && doc.icon ? (doc.icon.url || (Array.isArray(doc.icon) && doc.icon[0] && doc.icon[0].url)) : null; 1313 1313 const name = (doc && (doc.name || doc.preferredUsername)) || handle; 1314 // Een AS2 `url` mag een ARRAY van Links zijn -- onze eigen buildActor doet 1315 // dat (profiel + RSS), en een oudere consument stringde die array tot 1316 // "[object Object],[object Object]" in de mention-hrefs van een hulpvraag 1317 // (Barts vondst, 8-8). pickLink kiest de html-Link; de kale string blijft 1318 // de gewone weg, en de actor-id de terugval. 1319 const profiel = (doc && Array.isArray(doc.url)) 1320 ? ((pickLink(doc.url, (mt) => !mt || /html/i.test(mt)) || {}).href || safeUrl(doc.id || actorUri)) 1321 : safeUrl((doc && (doc.url || doc.id)) || actorUri); 1314 1322 return { 1315 1323 name, 1316 1324 handle, 1317 url: safeUrl((doc && (doc.url || doc.id)) || actorUri)|| null,1325 url: profiel || null, 1318 1326 icon: safeUrl(icon) || null, 1319 1327 // FEP-9098 custom emojis in the display name (":shortcode:"), so the byline -
test/own-card.test.js
rcae7bfc rc49808e 88 88 assert.deepEqual(await AP.previewCard('geen url'), {}); 89 89 }); 90 91 92 test('actorInfo kiest de html-Link uit een url-array (geen object-stringing)', async () => { 93 // Barts vondst (8-8): buildActor serveert `url` als array van Links 94 // (profiel + RSS), en een consument die dat niet kent stringde de array tot 95 // "[object Object],[object Object]" in de mention-href van een HULPVRAAG. 96 // De thread-byline loopt door dezelfde actorInfo, dus die legt het vast. 97 const HOST = 'https://203.0.113.62'; 98 const NOTE = `${HOST}/notes/n1`; 99 const AUTEUR = `${HOST}/users/array`; 100 const vorige = globalThis.fetch; 101 globalThis.fetch = async (url) => { 102 const u = String(url); 103 const json = (o) => new Response(JSON.stringify(o), { status: 200, headers: { 'content-type': 'application/activity+json' } }); 104 if (u === NOTE) return json({ 105 id: NOTE, type: 'Note', attributedTo: AUTEUR, content: '<p>bron</p>', 106 replies: { type: 'Collection', first: { type: 'CollectionPage', items: [ 107 { id: `${NOTE}/r1`, type: 'Note', attributedTo: AUTEUR, inReplyTo: NOTE, content: '<p>antwoord</p>', published: '2026-08-02T10:00:00Z' }, 108 ] } }, 109 }); 110 if (u === AUTEUR) return json({ 111 id: AUTEUR, type: 'Person', preferredUsername: 'array', inbox: `${AUTEUR}/inbox`, 112 url: [ 113 { type: 'Link', href: `${HOST}/`, mediaType: 'text/html' }, 114 { type: 'Link', href: `${HOST}/feed.xml`, mediaType: 'application/rss+xml' }, 115 ], 116 }); 117 return vorige(url); 118 }; 119 const uit = await AP.getThread('schrijver', NOTE); 120 globalThis.fetch = vorige; 121 assert.equal(uit.notes.length, 1); 122 const auteur = uit.notes[0]['shaer:author']; 123 assert.equal(auteur.url, `${HOST}/`, 'de html-Link, niet de array gestringd'); 124 assert.ok(!String(auteur.url).includes('object'), 'nergens [object Object]'); 125 });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)