best address logic

This commit is contained in:
Aiden McClelland
2025-08-07 17:15:23 -06:00
parent 4d5ff1a97b
commit 3845550e90
9 changed files with 119 additions and 107 deletions

View File

@@ -3,6 +3,7 @@ import { knownProtocols } from "../interfaces/Host"
import { AddressInfo, Host, Hostname, HostnameInfo } from "../types"
import { Effects } from "../Effects"
import { DropGenerator, DropPromise } from "./Drop"
import { IPV6_LINK_LOCAL } from "./ip"
export type UrlString = string
export type HostId = string
@@ -95,9 +96,9 @@ export const addressHostToUrl = (
hostname = host.hostname.value
} else if (host.kind === "ip") {
if (host.hostname.kind === "domain") {
hostname = `${host.hostname.subdomain ? `${host.hostname.subdomain}.` : ""}${host.hostname.domain}`
hostname = host.hostname.value
} else if (host.hostname.kind === "ipv6") {
hostname = host.hostname.value.startsWith("fe80::")
hostname = IPV6_LINK_LOCAL.contains(host.hostname.value)
? `[${host.hostname.value}%${host.hostname.scopeId}]`
: `[${host.hostname.value}]`
} else {