Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit fe68df9

Browse files
committed
Fix browser empty string flag parsing
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.
1 parent 4da70f2 commit fe68df9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

chromium/browser_type.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,15 @@ func parseArgs(flags map[string]any) ([]string, error) {
304304
for name, value := range flags {
305305
switch value := value.(type) {
306306
case string:
307-
args = append(args, fmt.Sprintf("--%s=%s", name, value))
307+
var arg string
308+
if strings.TrimSpace(value) != "" {
309+
arg = fmt.Sprintf("--%s=%s", name, value)
310+
} else {
311+
// If the value is empty, we don't include it in the args list.
312+
// Otherwise, it will produce "--name=" which is invalid.
313+
arg = fmt.Sprintf("--%s", name)
314+
}
315+
args = append(args, arg)
308316
case bool:
309317
if value {
310318
args = append(args, fmt.Sprintf("--%s", name))

0 commit comments

Comments
 (0)