fix: profile links lost on save due to qs body parser key mismatch

express.urlencoded({ extended: true }) uses qs which strips [] from
field names, so link_name[] arrives as request.body.link_name — not
request.body["link_name[]"]. The old lookup always got undefined,
producing an empty attachments array that overwrote existing links.
This commit is contained in:
Ricardo
2026-02-21 15:04:36 +01:00
parent 94844d5b4d
commit 348a183e46
2 changed files with 10 additions and 4 deletions

View File

@@ -50,9 +50,15 @@ export function profilePostController(mountPath, plugin) {
authorizedFetch,
} = request.body;
// Parse profile links (attachments) from form arrays
const linkNames = [].concat(request.body["link_name[]"] || []);
const linkValues = [].concat(request.body["link_value[]"] || []);
// Parse profile links (attachments) from form arrays.
// With express.urlencoded({ extended: true }), qs strips the []
// suffix so the data arrives as request.body.link_name (array).
const linkNames = [].concat(
request.body.link_name || request.body["link_name[]"] || [],
);
const linkValues = [].concat(
request.body.link_value || request.body["link_value[]"] || [],
);
const attachments = [];
for (let i = 0; i < linkNames.length; i++) {
const n = linkNames[i]?.trim();

View File

@@ -1,6 +1,6 @@
{
"name": "@rmdes/indiekit-endpoint-activitypub",
"version": "1.1.7",
"version": "1.1.8",
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
"keywords": [
"indiekit",