From 2521b47ef1e0094f8bac6ec152e96291094d3421 Mon Sep 17 00:00:00 2001 From: Balazs Czoma Date: Tue, 5 Mar 2024 04:53:55 -0500 Subject: [PATCH] Generated code updates from template --- main.tf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index f1e04b9..d05c128 100644 --- a/main.tf +++ b/main.tf @@ -15,8 +15,10 @@ locals { tls = startswith(lower(var.url), "https:") slashSplit = split("/", var.url) - isIpV6HostPort = length(split("]", local.slashSplit[2])) == 2 - hostPortSplit = local.isIpV6HostPort ? split("]:", trimprefix(local.slashSplit[2], "[")) : split(":", local.slashSplit[2]) + isIpV6HostWithPort = length(split("]", local.slashSplit[2])) == 2 + isIpV6NoPort = local.isIpV6HostWithPort ? false : length(split(":", local.slashSplit[2])) > 2 + address = local.isIpV6NoPort ? join(local.slashSplit[2], ["[", "]"]) : local.slashSplit[2] + hostPortSplit = local.isIpV6HostWithPort || local.isIpV6NoPort ? split("]:", trimprefix(local.address, "[")) : split(":", local.address) host = trimsuffix(local.hostPortSplit[0], "]") port = length(local.hostPortSplit) == 2 ? tonumber(local.hostPortSplit[1]) : (local.tls ? 443 : 80) path = "/${join("/", slice(local.slashSplit, 3, length(local.slashSplit)))}"