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:
@@ -50,9 +50,15 @@ export function profilePostController(mountPath, plugin) {
|
|||||||
authorizedFetch,
|
authorizedFetch,
|
||||||
} = request.body;
|
} = request.body;
|
||||||
|
|
||||||
// Parse profile links (attachments) from form arrays
|
// Parse profile links (attachments) from form arrays.
|
||||||
const linkNames = [].concat(request.body["link_name[]"] || []);
|
// With express.urlencoded({ extended: true }), qs strips the []
|
||||||
const linkValues = [].concat(request.body["link_value[]"] || []);
|
// 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 = [];
|
const attachments = [];
|
||||||
for (let i = 0; i < linkNames.length; i++) {
|
for (let i = 0; i < linkNames.length; i++) {
|
||||||
const n = linkNames[i]?.trim();
|
const n = linkNames[i]?.trim();
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
"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.",
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"indiekit",
|
"indiekit",
|
||||||
|
|||||||
Reference in New Issue
Block a user