From f592092ce060960b5f919a172a6b39ccb43e414a Mon Sep 17 00:00:00 2001 From: Benedikt Strehle Date: Tue, 30 Jan 2024 20:01:45 +0100 Subject: [PATCH] Create format-endpoint-url.ts --- utils/format-endpoint-url.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 utils/format-endpoint-url.ts diff --git a/utils/format-endpoint-url.ts b/utils/format-endpoint-url.ts new file mode 100644 index 00000000..5ac0835c --- /dev/null +++ b/utils/format-endpoint-url.ts @@ -0,0 +1,12 @@ +import { Endpoint, Institution, Person } from "../types/addressing.ts"; + +export function formatEndpointURL(endpoint:Endpoint) { + const domainName = normalizeDomainName(endpoint.name); + if (endpoint instanceof Institution) return `${domainName}.unyt.app` + else if (endpoint instanceof Person) return `${domainName}.unyt.app` // TODO: unyt.me? + else return `${domainName}.unyt.app` +} + +function normalizeDomainName(name: string) { + return name.replaceAll("_", "-"); +}