openclaw/src/infra/net/hostname.ts
2026-02-16 01:01:22 +00:00

8 lines
260 B
TypeScript

export function normalizeHostname(hostname: string): string {
const normalized = hostname.trim().toLowerCase().replace(/\.$/, "");
if (normalized.startsWith("[") && normalized.endsWith("]")) {
return normalized.slice(1, -1);
}
return normalized;
}