Skip to content

Commit

Permalink
Fix browser empty string flag parsing
Browse files Browse the repository at this point in the history
Currently, passing a flag that doesn't contain a value to
K6_BROWSER_ARGS results in an argument with an equal sign suffix:

K6_BROWSER_ARGS=disable-site-isolation-trials

Results in:
disable-site-isolation-trials=

Instead of:
disable-site-isolation-trials

This PR fixes this problem.
  • Loading branch information
inancgumus committed Jun 13, 2024
1 parent 4da70f2 commit a6c0b99
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chromium/browser_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,15 @@ func parseArgs(flags map[string]any) ([]string, error) {
for name, value := range flags {
switch value := value.(type) {
case string:
args = append(args, fmt.Sprintf("--%s=%s", name, value))
var arg string
if strings.TrimSpace(value) != "" {
arg = fmt.Sprintf("--%s=%s", name, value)
} else {
// If the value is empty, we don't include it in the args list.
// Otherwise, it will produce "--name=" which is invalid.
arg = fmt.Sprintf("--%s", name)
}
args = append(args, arg)
case bool:
if value {
args = append(args, fmt.Sprintf("--%s", name))
Expand Down

0 comments on commit a6c0b99

Please sign in to comment.