From 25f64738e4ec2ad78e05be3a7959788c81fcb65c Mon Sep 17 00:00:00 2001 From: Nebulosa <85841412+nebulosa2007@users.noreply.github.com> Date: Sun, 8 Feb 2026 01:01:05 +0300 Subject: [PATCH] refactor: set header only if it not empty (#3763) --- sub/subController.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/sub/subController.go b/sub/subController.go index 53b5580b..ffd657a1 100644 --- a/sub/subController.go +++ b/sub/subController.go @@ -182,10 +182,24 @@ func (a *SUBController) ApplyCommonHeaders( ) { c.Writer.Header().Set("Subscription-Userinfo", header) c.Writer.Header().Set("Profile-Update-Interval", updateInterval) - c.Writer.Header().Set("Profile-Title", "base64:"+base64.StdEncoding.EncodeToString([]byte(profileTitle))) - c.Writer.Header().Set("Support-Url", profileSupportUrl) - c.Writer.Header().Set("Profile-Web-Page-Url", profileUrl) - c.Writer.Header().Set("Announce", "base64:"+base64.StdEncoding.EncodeToString([]byte(profileAnnounce))) + + //Basics + if profileTitle != "" { + c.Writer.Header().Set("Profile-Title", "base64:"+base64.StdEncoding.EncodeToString([]byte(profileTitle))) + } + if profileSupportUrl != "" { + c.Writer.Header().Set("Support-Url", profileSupportUrl) + } + if profileUrl != "" { + c.Writer.Header().Set("Profile-Web-Page-Url", profileUrl) + } + if profileAnnounce != "" { + c.Writer.Header().Set("Announce", "base64:"+base64.StdEncoding.EncodeToString([]byte(profileAnnounce))) + } + + //Advanced (Happ) c.Writer.Header().Set("Routing-Enable", strconv.FormatBool(profileEnableRouting)) - c.Writer.Header().Set("Routing", profileRoutingRules) + if profileRoutingRules != "" { + c.Writer.Header().Set("Routing", profileRoutingRules) + } }