diff --git a/src/extractors/x-article.ts b/src/extractors/x-article.ts index d65a25a32..e3948abf8 100644 --- a/src/extractors/x-article.ts +++ b/src/extractors/x-article.ts @@ -69,8 +69,9 @@ export class XArticleExtractor extends BaseExtractor { } private getAuthorFromUrl(): string { - // match username before /article/, excluding system paths like /i/ - const match = this.url.match(/\/([a-zA-Z][a-zA-Z0-9_]{0,14})\/article\/\d+/); + // X articles can render on both /article/ and /status/ URLs. + // Prefer the handle from the URL when available, excluding system paths like /i/. + const match = this.url.match(/\/([a-zA-Z][a-zA-Z0-9_]{0,14})\/(?:status|article)\/\d+/); return match ? `@${match[1]}` : this.getAuthorFromOgTitle(); } diff --git a/tests/expected/general--x.com-status-localized-author.md b/tests/expected/general--x.com-status-localized-author.md new file mode 100644 index 000000000..74303f1ba --- /dev/null +++ b/tests/expected/general--x.com-status-localized-author.md @@ -0,0 +1,12 @@ +```json +{ + "title": "Localized author fallback example", + "author": "@sample_user", + "site": "X (Twitter)", + "published": "" +} +``` + +This fixture simulates an X article rendered on a status URL without an inline author block. + +The author should fall back to the handle embedded in the page URL. diff --git a/tests/fixtures/general--x.com-status-localized-author.html b/tests/fixtures/general--x.com-status-localized-author.html new file mode 100644 index 000000000..160c262c1 --- /dev/null +++ b/tests/fixtures/general--x.com-status-localized-author.html @@ -0,0 +1,24 @@ + + + +
+ + +