mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
refactor(app): derive native-feed base from EmailAddress.siteBaseUrl
Delete the `iconBase` local helper (which mishandled display-name form like `Name <a@b.com>`) and replace it with `EmailAddress.parse(input.from) ?.siteBaseUrl()` — the domain-layer VO that already handles bare and display-name addresses correctly. Adds TEST C to lock the display-name + relative-href absolutization fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { MailboxId } from "../domain/value-objects/mailbox-id";
|
||||
import { EmailAddress } from "../domain/value-objects/email-address";
|
||||
import { AttachmentData, EmailMetadata, Env } from "../types";
|
||||
import { bumpCounters } from "../application/stats";
|
||||
import { dispatchFeedEvents } from "../application/feed-events";
|
||||
@@ -20,13 +21,6 @@ import { Feed } from "../domain/feed.aggregate";
|
||||
import { logger } from "../infrastructure/logger";
|
||||
import { FEED_MAX_BYTES } from "../config/constants";
|
||||
|
||||
// Best-effort site base for absolutizing a sender's relative feed link.
|
||||
function iconBase(from: string): string {
|
||||
const at = from.lastIndexOf("@");
|
||||
const domain = at >= 0 ? from.slice(at + 1).trim() : "";
|
||||
return domain ? `https://${domain}` : "";
|
||||
}
|
||||
|
||||
export interface RawAttachment {
|
||||
filename: string;
|
||||
contentType: string;
|
||||
@@ -203,7 +197,10 @@ async function storeEmail(
|
||||
});
|
||||
|
||||
const nativeFeedList = detectNativeFeeds(
|
||||
extractFeedLinks(input.content, iconBase(input.from)),
|
||||
extractFeedLinks(
|
||||
input.content,
|
||||
EmailAddress.parse(input.from)?.siteBaseUrl() ?? "",
|
||||
),
|
||||
);
|
||||
|
||||
const attachmentBucket = getAttachmentBucket(env);
|
||||
|
||||
Reference in New Issue
Block a user