From 83158165bdd7146f4402e4e73ccf0317f789e470 Mon Sep 17 00:00:00 2001 From: Ian Shim <100327837+ian-shim@users.noreply.github.com> Date: Wed, 1 May 2024 09:28:36 -0700 Subject: [PATCH] Handle empty strings in flag name concatenation (#535) --- common/common.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/common.go b/common/common.go index 2709af28c4..90baeb87e6 100644 --- a/common/common.go +++ b/common/common.go @@ -10,11 +10,23 @@ import ( // PrefixEnvVar returns the environment variable name with the given prefix and suffix func PrefixEnvVar(prefix, suffix string) string { + if prefix == "" { + return suffix + } + if suffix == "" { + return prefix + } return prefix + "_" + suffix } // PrefixFlag returns the flag name with the given prefix and suffix func PrefixFlag(prefix, suffix string) string { + if prefix == "" { + return suffix + } + if suffix == "" { + return prefix + } return prefix + "." + suffix }