From 94844d5b4da72af766bcf4bd07b6e6cb7fb6a647 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sat, 21 Feb 2026 15:00:29 +0100 Subject: [PATCH] fix: extract correct username from /users/name URL pattern The attributionIds fallback was matching "users" from /users/NatalieDavis instead of the actual username. Now handles /@name, /users/name, and /ap/users/id patterns correctly. --- lib/timeline-store.js | 17 +++++++++++++---- package.json | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/timeline-store.js b/lib/timeline-store.js index 8537acb..4501c2b 100644 --- a/lib/timeline-store.js +++ b/lib/timeline-store.js @@ -155,10 +155,19 @@ export async function extractObjectData(object, options = {}) { const attrIds = object.attributionIds; if (attrIds && attrIds.length > 0) { const authorUrl = attrIds[0].href; - const authorHostname = new URL(authorUrl).hostname; - // Extract username from URL pattern like /users/name or /@name - const pathMatch = new URL(authorUrl).pathname.match(/\/@?([^/]+)/); - const username = pathMatch ? pathMatch[1] : ""; + const parsedUrl = new URL(authorUrl); + const authorHostname = parsedUrl.hostname; + // Extract username from common URL patterns: + // /@username, /users/username, /ap/users/12345/ + const pathname = parsedUrl.pathname; + let username = ""; + const atPattern = pathname.match(/\/@([^/]+)/); + const usersPattern = pathname.match(/\/users\/([^/]+)/); + if (atPattern) { + username = atPattern[1]; + } else if (usersPattern) { + username = usersPattern[1]; + } author = { name: username || authorHostname, url: authorUrl, diff --git a/package.json b/package.json index 8ea9c87..d11002b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-activitypub", - "version": "1.1.6", + "version": "1.1.7", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "keywords": [ "indiekit",