refactor(app): derive native-feed base from EmailAddress.siteBaseUrl

Delete the `iconBase` local helper (which mishandled display-name form
like `Name <[email protected]>`) 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 <[email protected]>
This commit is contained in:
Julien HerrandClaude Sonnet 4.6 committed 2026-05-25 17:25:52 +02:00
1 parent 5362d478e3
commit 6236274ce8
2 files changed
+29 -8

No files matched your search

+24
View File
@@ -1047,4 +1047,28 @@ describe("native feed detection on ingest", () => {
)) as { nativeFeeds?: Record<string, unknown> };
expect(metadata.nativeFeeds).toBeUndefined();
});
it("absolutizes a relative feed href using the display-name sender's domain (TEST C)", async () => {
const result = await processEmail(
makeInput({
from: "Blog Name <[email protected]>",
senders: ["[email protected]"],
content:
'<html><head><link rel="alternate" type="application/atom+xml" href="/atom.xml"></head><body>hi</body></html>',
}),
env as any,
);
expect(result.ok).toBe(true);
const metadata = (await env.EMAIL_STORAGE.get(
`feed:${VALID_FEED_ID}:metadata`,
"json",
)) as {
nativeFeeds?: Record<string, Array<{ url: string; type: string }>>;
};
expect(Object.values(metadata.nativeFeeds!).flat()).toEqual([
{ url: "https://blog.example.com/atom.xml", type: "atom" },
]);
});
});