8 lines
260 B
TypeScript
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;
|
|
}
|