From 70f21d5f7eb486875d6f6f07c858c7d20e9b3f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Werner?= Date: Wed, 21 Feb 2024 21:18:56 +0100 Subject: [PATCH] fix cors domain normalize --- middleware/cors/utils.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/middleware/cors/utils.go b/middleware/cors/utils.go index 313a430c77..d1280899c9 100644 --- a/middleware/cors/utils.go +++ b/middleware/cors/utils.go @@ -49,8 +49,10 @@ func normalizeDomain(input string) string { input = strings.TrimPrefix(strings.TrimPrefix(input, "http://"), "https://") // Find and remove port, if present - if portIndex := strings.Index(input, ":"); portIndex != -1 { - input = input[:portIndex] + if len(input) > 0 && input[0] != '[' { + if portIndex := strings.Index(input, ":"); portIndex != -1 { + input = input[:portIndex] + } } return input