refactor(net): share hostname normalization

This commit is contained in:
Peter Steinberger
2026-02-16 01:01:22 +00:00
parent d5ee766afe
commit 4aaafe5322
3 changed files with 9 additions and 16 deletions

View File

@@ -1,17 +1,10 @@
import type { WebClient as SlackWebClient } from "@slack/web-api";
import type { FetchLike } from "../../media/fetch.js";
import type { SlackFile } from "../types.js";
import { normalizeHostname } from "../../infra/net/hostname.js";
import { fetchRemoteMedia } from "../../media/fetch.js";
import { saveMediaBuffer } from "../../media/store.js";
function normalizeHostname(hostname: string): string {
const normalized = hostname.trim().toLowerCase().replace(/\.$/, "");
if (normalized.startsWith("[") && normalized.endsWith("]")) {
return normalized.slice(1, -1);
}
return normalized;
}
function isSlackHostname(hostname: string): boolean {
const normalized = normalizeHostname(hostname);
if (!normalized) {