mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-26 16:06:16 +00:00
refactor: share net and slack input helpers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user