Changeset 0677bac in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 08/09/2026 08:24:16 AM (4 weeks ago)
- Branches:
- main
- Children:
- d60c498
- Parents:
- a5d14c7
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
ra5d14c7 r0677bac 29 29 import Blocklist from './BlocklistService.js'; 30 30 import * as Guardianship from './guardianship/index.js'; 31 import { PUBLIC, AP_CONTEXT, safeUrl, actorId, noteId, guessMediaType } from './ap-core.js';31 import { PUBLIC, AP_CONTEXT, safeUrl, actorId, noteId, guessMediaType, normalizeTags, tagParts } from './ap-core.js'; 32 32 // Doorgeven wat hier altijd vandaan kwam, zodat elke bestaande aanroep blijft werken. 33 33 export { AP_CONTEXT, actorId, noteId, guessMediaType }; … … 2973 2973 2974 2974 // Normalise a post's tags field (array, JSON-string, or comma-string) to an array. 2975 function normalizeTags(t) { 2976 if (Array.isArray(t)) return t; 2977 if (typeof t === 'string') { 2978 const s = t.trim(); if (!s) return []; 2979 if (s[0] === '[') { try { const a = JSON.parse(s); return Array.isArray(a) ? a : []; } catch { /* fall through */ } } 2980 return s.split(',').map((x) => x.trim()).filter(Boolean); 2981 } 2982 return []; 2983 } 2975 // normalizeTags en tagParts staan sinds shaer-38y in ap-core: music/ heeft ze 2976 // ook nodig en mag hier niet uit importeren. 2984 2977 // A tag → { label, slug }. Multi-word tags become CamelCase (#LiveMusic) for the display 2985 2978 // name (Mastodon hashtags can't contain spaces; CamelCase is the accessibility norm); the 2986 2979 // slug/href stays lowercase ("livemusic"). 2987 function tagParts(raw) {2988 const words = String(raw || '').trim().split(/[\s_]+/).map((w) => w.replace(/[^\p{L}\p{M}\p{N}]/gu, '')).filter(Boolean);2989 if (!words.length) return null;2990 const slug = words.join('').toLowerCase();2991 if (!slug) return null;2992 const label = words.length > 1 ? words.map((w) => w[0].toUpperCase() + w.slice(1)).join('') : words[0];2993 return { label, slug };2994 }2995 2980 // Merge a post's tags field + the #hashtags linked inline in its body into one deduped 2996 2981 // Hashtag tag list (with hrefs to our /tag page).
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)