mirror of
https://github.com/drone/drone-cli.git
synced 2026-01-27 05:18:02 +01:00
Allow values in key/value pairs to contain '=' characters
This commit is contained in:
parent
e963f924a2
commit
06de2e587d
@ -87,7 +87,7 @@ func ParseRepo(str string) (user, repo string, err error) {
|
||||
func ParseKeyPair(p []string) map[string]string {
|
||||
params := map[string]string{}
|
||||
for _, i := range p {
|
||||
parts := strings.Split(i, "=")
|
||||
parts := strings.SplitN(i, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -3,11 +3,14 @@ package internal
|
||||
import "testing"
|
||||
|
||||
func TestParseKeyPair(t *testing.T) {
|
||||
s := []string{"FOO=bar", "BAR=", "INVALID"}
|
||||
s := []string{"FOO=bar", "BAR=", "BAZ=qux=quux", "INVALID"}
|
||||
p := ParseKeyPair(s)
|
||||
if p["FOO"] != "bar" {
|
||||
t.Errorf("Wanted %q, got %q.", "bar", p["FOO"])
|
||||
}
|
||||
if p["BAZ"] != "qux=quux" {
|
||||
t.Errorf("Wanted %q, got %q.", "qux=quux", p["BAZ"])
|
||||
}
|
||||
if _, exists := p["BAR"]; !exists {
|
||||
t.Error("Missing a key with no value. Keys with empty values are also valid.")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user