Skip to content

Commit

Permalink
fix: double hash in value (#213)
Browse files Browse the repository at this point in the history
* fix: double hash in value

Signed-off-by: Kasper J. Hermansen <contact@kjuulh.io>

* chore: add test

Signed-off-by: Kasper J. Hermansen <contact@kjuulh.io>

* fix: in value

Signed-off-by: Kasper J. Hermansen <contact@kjuulh.io>

---------

Signed-off-by: Kasper J. Hermansen <contact@kjuulh.io>
  • Loading branch information
kjuulh committed Jan 12, 2024
1 parent 3b24879 commit cc7d41a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ func newRunSubCommand(
}

parseKeyValuePair := func(arg string) (string, string, bool) {
keyvaluearg := strings.Split(arg, "=")
if len(keyvaluearg) == 2 {
key := keyvaluearg[0]
value := keyvaluearg[1]

return key, value, true
before, after, found := strings.Cut(arg, "=")
if found {
return before, after, true
}

return "", "", false
Expand Down
7 changes: 7 additions & 0 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ Global Flags:
erroutput: "",
err: nil,
},
{
name: "script succeeds with required argument with hash in value",
input: args("-p", "testdata/project", "run", "required_arg", "foo=bar="),
stdoutput: "bar=\n",
erroutput: "",
err: nil,
},
{
name: "script succeeds with required argument missing and validation disabled",
input: args("-p", "testdata/project", "run", "--validate=false", "required_arg"),
Expand Down

0 comments on commit cc7d41a

Please sign in to comment.