Skip to content

Commit

Permalink
Merge pull request #80 from Illianthe/parse-key-value
Browse files Browse the repository at this point in the history
Allow values in key/value pairs to contain '=' characters
  • Loading branch information
tboerger committed Jan 31, 2018
2 parents e963f92 + 06de2e5 commit f1e221f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drone/internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion drone/internal/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down

0 comments on commit f1e221f

Please sign in to comment.