Changeset e00c0e9 in Klonkt
- Timestamp:
- 07/01/2026 10:06:57 PM (2 months ago)
- Branches:
- main
- Children:
- 254939c
- Parents:
- d11e308
- Files:
-
- 1 added
- 4 edited
-
CHANGELOG.de.md (modified) (1 diff)
-
CHANGELOG.md (modified) (1 diff)
-
CHANGELOG.nl.md (modified) (1 diff)
-
src/services/ActivityPubService.js (modified) (4 diffs)
-
test/url-linkify.test.js (added)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG.de.md
rd11e308 re00c0e9 35 35 ist die Datei verbreitet — erneutes "Schließen" wäre Scheinsicherheit. Der Editor sperrt die Wahl 36 36 nach dem Öffnen und warnt dich, bevor du sie ankreuzt. 37 38 ### Behoben 39 - **Nackte Webadressen werden im Fediverse zu Links.** Eine einfache URL in einem Beitrag oder einer 40 Antwort föderiert jetzt als klickbarer Link statt als reiner Text. 37 41 38 42 ## [1.2.0] — 2026-07-01 -
CHANGELOG.md
rd11e308 re00c0e9 30 30 has spread, so "closing" it again would be false security — the editor now locks the choice after 31 31 opening and warns you before you tick it. 32 33 ### Fixed 34 - **Plain web addresses become links on the fediverse.** A bare URL typed in a post or reply now 35 federates as a clickable link instead of plain text. 32 36 33 37 ## [1.2.0] — 2026-07-01 -
CHANGELOG.nl.md
rd11e308 re00c0e9 33 33 is het bestand verspreid — weer "sluiten" zou schijnveiligheid zijn. De editor vergrendelt de keuze 34 34 na het openen en waarschuwt je voordat je 'm aanvinkt. 35 36 ### Opgelost 37 - **Kale webadressen worden links op de fediverse.** Een losse URL in een post of reactie federeert 38 nu als klikbare link in plaats van platte tekst. 35 39 36 40 ## [1.2.0] — 2026-07-01 -
src/services/ActivityPubService.js
rd11e308 re00c0e9 343 343 body = body.replace(/\r?\n/g, '<br>'); 344 344 body = linkHashtags(base, body); // link inline #hashtags in the post body too 345 body = linkUrls(body); // bare URLs → clickable links on the federated copy 345 346 // Append the tags-field hashtags to the content so Mastodon renders them as clickable 346 347 // hashtags (a Hashtag that's only in the `tag` array isn't shown inline). CamelCase … … 1371 1372 `${pre}<a href="${base}/tag/${encodeURIComponent(tag.toLowerCase())}" class="mention hashtag" rel="tag">#${tag}</a>`); 1372 1373 } 1374 // Auto-link bare http(s) URLs in already-safe HTML (federated copies). Splits on existing 1375 // <a>…</a> so a linked URL is never wrapped twice; requires start/whitespace/'>' before the 1376 // URL so attribute values (src="https://…") never match. Trailing sentence punctuation stays 1377 // outside the link (Mastodon-style). 1378 function linkUrls(html) { 1379 const parts = String(html || '').split(/(<a\b[^>]*>[\s\S]*?<\/a>)/gi); 1380 for (let i = 0; i < parts.length; i++) { 1381 if (/^<a\b/i.test(parts[i])) continue; // already a link → leave as-is 1382 parts[i] = parts[i].replace(/(^|[\s>])(https?:\/\/[^\s<]+?)([.,;:!?)\]»]*)(?=$|[\s<])/g, 1383 (m, pre, url, trail) => `${pre}<a href="${url.replace(/"/g, '%22')}" rel="nofollow noopener" target="_blank">${url}</a>${trail}`); 1384 } 1385 return parts.join(''); 1386 } 1373 1387 // Extract the AP Hashtag tag objects from already-linked reply content. 1374 1388 function hashtagTags(base, content) { … … 1497 1511 const mention = parent.actor_uri 1498 1512 ? `<a href="${escHtml(parent.actor_url || parent.actor_uri)}" class="u-url mention" data-actor="${escHtml(parent.actor_uri)}">${escHtml(dispHandle)}</a> ` : ''; 1499 const content = `<p>${mention}${link Hashtags(base, mres.html)}</p>`;1513 const content = `<p>${mention}${linkUrls(linkHashtags(base, mres.html))}</p>`; 1500 1514 // Dedup: skip if the exact same reply was already sent (double-submit guard). 1501 1515 const dup = db.prepare('SELECT 1 FROM ap_outbox WHERE site_slug = ? AND IFNULL(in_reply_to, \'\') = ? AND content = ? LIMIT 1') … … 1657 1671 ? `<a href="${escHtml(toProfile)}" class="u-url mention" data-actor="${escHtml(row.to_actor)}">${escHtml(toHandle)}</a> ` : ''; 1658 1672 const mres = await resolveMentionsInText(base, escHtml(text).replace(/\r?\n/g, '<br>')); 1659 const content = `<p>${mention}${link Hashtags(base, mres.html)}</p>`;1673 const content = `<p>${mention}${linkUrls(linkHashtags(base, mres.html))}</p>`; 1660 1674 db.prepare('UPDATE ap_outbox SET content = ? WHERE id = ?').run(content, outboxId); 1661 1675 const note = buildReplyNote(base, site, iStmts().getO.get(outboxId));
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)