From 16bf92be5af307cf32013eabc59c7747dae37eb3 Mon Sep 17 00:00:00 2001 From: ivan katliarchuk Date: Mon, 27 Jan 2025 09:49:57 +0000 Subject: [PATCH] rollback to if checks Signed-off-by: ivan katliarchuk --- provider/aws/aws.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 6b0a3bf7e..25f3cee4e 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -1159,13 +1159,10 @@ func isAWSAlias(ep *endpoint.Endpoint) string { return "" } -var regex = regexp.MustCompile(`(aws.com(.cn)?|tor.com|ont.(com|net))$`) - // canonicalHostedZone returns the matching canonical zone for a given hostname. func canonicalHostedZone(hostname string) string { // strings.HasSuffix is optimized for this specific task and avoids the overhead associated with compiling and executing a regular expression. - if regex.MatchString(hostname) { - // if strings.HasSuffix(hostname, "aws.com") || strings.HasSuffix(hostname, "aws.com.cn") || strings.HasSuffix(hostname, "tor.com") || strings.HasSuffix(hostname, "ont.com") || strings.HasSuffix(hostname, "ont.net") { + if strings.HasSuffix(hostname, "aws.com") || strings.HasSuffix(hostname, "aws.com.cn") || strings.HasSuffix(hostname, "tor.com") || strings.HasSuffix(hostname, "ont.com") || strings.HasSuffix(hostname, "ont.net") { parts := strings.Split(hostname, ".") // iterate from the second-last part (zone) towards the beginning for i := len(parts) - 2; i >= 0; i-- {