mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
* Feature: Add in the clear bindings * wip: Working on network * fix: Make it so the config gives the url * chore: Remove the repeated types * chore: Add in the todo's here * chore: UPdate and remove some poorly name var * chore: Remove the clear-bindings impl * chore: Remove the wrapper * handle HostnameInfo for Host bindings Co-authored-by: Jade <Blu-J@users.noreply.github.com> * ?? * chore: Make the install work * Fix: Url's not being created * chore: Fix the local onion in url * include port in hostname * Chore of adding a comment just to modify. --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Jade <Blu-J@users.noreply.github.com>
26 lines
822 B
TypeScript
26 lines
822 B
TypeScript
import { HostnameInfo } from "../types"
|
|
|
|
export function hostnameInfoToAddress(hostInfo: HostnameInfo): string {
|
|
if (hostInfo.kind === "onion") {
|
|
return `${hostInfo.hostname.value}`
|
|
}
|
|
if (hostInfo.kind !== "ip") {
|
|
throw Error("Expecting that the kind is ip.")
|
|
}
|
|
const hostname = hostInfo.hostname
|
|
if (hostname.kind === "domain") {
|
|
return `${hostname.subdomain ? `${hostname.subdomain}.` : ""}${hostname.domain}`
|
|
}
|
|
const port = hostname.sslPort || hostname.port
|
|
const portString = port ? `:${port}` : ""
|
|
if ("ipv4" === hostname.kind || "ipv6" === hostname.kind) {
|
|
return `${hostname.value}${portString}`
|
|
}
|
|
if ("local" === hostname.kind) {
|
|
return `${hostname.value}${portString}`
|
|
}
|
|
throw Error(
|
|
"Expecting to have a valid hostname kind." + JSON.stringify(hostname),
|
|
)
|
|
}
|