Skip to content

Commit

Permalink
Merge pull request #3978 from ripcurlx/accept-empty-option-values
Browse files Browse the repository at this point in the history
Accept empty config values
  • Loading branch information
sqrrm authored Feb 17, 2020
2 parents a3f4f7c + 3899f69 commit c411f48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static ConfigFileOption parse(String option) {

String[] tokens = clean(option).split("=");
String name = tokens[0].trim();
String arg = tokens[1].trim();
String arg = tokens.length > 1 ? tokens[1].trim() : "";
return new ConfigFileOption(name, arg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ public void whenOptionHasEscapedColons_thenTheyGetUnescaped() {
assertThat(option.arg, equalTo("example.com:8080"));
assertThat(option.toString(), equalTo("host1=example.com:8080"));
}

@Test
public void whenOptionHasNoValue_thenItSetsEmptyValue() {
String value = "host1=";
ConfigFileOption option = ConfigFileOption.parse(value);
assertThat(option.name, equalTo("host1"));
assertThat(option.arg, equalTo(""));
assertThat(option.toString(), equalTo("host1="));
}
}

0 comments on commit c411f48

Please sign in to comment.