refactor: share net and slack input helpers

This commit is contained in:
Peter Steinberger
2026-03-13 21:58:16 +00:00
parent b5eb329f94
commit 854df8352c
2 changed files with 23 additions and 25 deletions

View File

@@ -128,12 +128,16 @@ function normalizeIpv4MappedAddress(address: ParsedIpAddress): ParsedIpAddress {
return address.toIPv4Address();
}
export function parseCanonicalIpAddress(raw: string | undefined): ParsedIpAddress | undefined {
function normalizeIpParseInput(raw: string | undefined): string | undefined {
const trimmed = raw?.trim();
if (!trimmed) {
return undefined;
}
const normalized = stripIpv6Brackets(trimmed);
return stripIpv6Brackets(trimmed);
}
export function parseCanonicalIpAddress(raw: string | undefined): ParsedIpAddress | undefined {
const normalized = normalizeIpParseInput(raw);
if (!normalized) {
return undefined;
}
@@ -150,11 +154,7 @@ export function parseCanonicalIpAddress(raw: string | undefined): ParsedIpAddres
}
export function parseLooseIpAddress(raw: string | undefined): ParsedIpAddress | undefined {
const trimmed = raw?.trim();
if (!trimmed) {
return undefined;
}
const normalized = stripIpv6Brackets(trimmed);
const normalized = normalizeIpParseInput(raw);
if (!normalized) {
return undefined;
}