refactor: centralize message provider normalization

This commit is contained in:
Peter Steinberger committed 2026-01-07 23:53:38 +00:00
1 parent b03a1ad814
commit 8b4bcc6b7a
8 files changed
+61 -52

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
export function normalizeMessageProvider(
raw?: string | null,
): string | undefined {
const normalized = raw?.trim().toLowerCase();
if (!normalized) return undefined;
return normalized === "imsg" ? "imessage" : normalized;
}
export function resolveMessageProvider(
primary?: string | null,
fallback?: string | null,
): string | undefined {
return (
normalizeMessageProvider(primary) ?? normalizeMessageProvider(fallback)
);
}