Skip to content

Commit

Permalink
Accept empty config values
Browse files Browse the repository at this point in the history
  • Loading branch information
ripcurlx committed Feb 17, 2020
1 parent 0083343 commit 3899f69
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 3899f69

Please sign in to comment.