From c6002b55794c28ccd099f4a3b1c65ef97324a114 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 23 Sep 2024 18:45:27 +0200 Subject: [PATCH] implement conditional surround functionality --- proxy/util.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proxy/util.go b/proxy/util.go index 59f0e14..8e25fff 100644 --- a/proxy/util.go +++ b/proxy/util.go @@ -2,6 +2,7 @@ package proxy import ( "errors" + "fmt" "strings" "github.com/Baipyrus/ProxySwitcher/util" @@ -31,6 +32,11 @@ func applyProxy(configArgs []string, configCmd, proxyServer string, variant *uti return configArgs, configCmd } + // Surround 'proxyServer' with any given string, if provided + if variant.Surround != "" { + proxyServer = fmt.Sprintf("%[1]s%[2]s%[1]s", variant.Surround, proxyServer) + } + // Insert proxy only on last VARIABLE type if variant.Type == util.VARIABLE && strings.Count(configCmd, "$PRSW_ARG") == 1 { configCmd = strings.Replace(configCmd, "$PRSW_ARG", proxyServer, 1)