mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
refactor(domain): add FeedId, EmailAddress and Domain value objects
Encapsulate the email/domain/feed-id parsing that was scattered as ad-hoc
regexes and split("@") calls into three small immutable value objects under
src/domain/value-objects/. EmailParser.extractFeedId and generateFeedId now
delegate to FeedId; the sender policy, favicon domain extraction and the admin
SenderField parse through EmailAddress/Domain.
Left as-is on purpose: forwardemail's multi-address free-text extraction and the
admin allow/block list normaliser, which operate on mixed email-or-domain input
that the single-address value objects would reject.
Behaviour-preserving; adds unit tests for each value object.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { EmailData } from "../types";
|
||||
import { FeedId } from "../domain/value-objects/feed-id";
|
||||
|
||||
export class EmailParser {
|
||||
// Matches noun1.noun2.XY (the feed ID format) before the @ symbol
|
||||
static extractFeedId(emailAddress: string): string | null {
|
||||
const match = emailAddress.match(/^([a-z]+\.[a-z]+\.\d{2})@/i);
|
||||
return match ? match[1] : null;
|
||||
return FeedId.parse(emailAddress)?.value ?? null;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
Reference in New Issue
Block a user