From a621135ac01784bbeb80ab34f59a7de7b80a2f24 Mon Sep 17 00:00:00 2001 From: Stavros Date: Sun, 15 Jun 2025 19:55:03 +0300 Subject: [PATCH] refactor: use splitn in header parser --- internal/utils/utils.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index cd3eaee..2c5969e 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -181,12 +181,14 @@ func ParseHeaders(headers []string) map[string]string { // Loop through the headers for _, header := range headers { - headerSplit := strings.Split(header, "=") - if len(headerSplit) != 2 { + split := strings.SplitN(header, "=", 2) + if len(split) != 2 { log.Warn().Str("header", header).Msg("Invalid header format, skipping") continue } - headerMap[headerSplit[0]] = SanitizeHeader(headerSplit[1]) + key := SanitizeHeader(strings.TrimSpace(split[0])) + value := SanitizeHeader(strings.TrimSpace(split[1])) + headerMap[key] = value } // Return the header map