Skip to content

Commit

Permalink
Merge pull request #115 from zmstone/1106-allow-space-in-hosts-string
Browse files Browse the repository at this point in the history
fix(kpro_lib): ignore space in bootstrap endpoints string
  • Loading branch information
zmstone authored Nov 6, 2023
2 parents 72d5073 + 614425c commit 5d55105
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 4.1.4
- Ignore space in comma-separated hosts string.
- Add more detailed information when server returned API version range is not supported.

* 4.1.3
- Bump snappyer dependency from 1.2.8 to 1.2.9 (supports GCC 13).
- Fix scram auth client final message.
Expand Down
2 changes: 1 addition & 1 deletion src/kpro_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ parse_endpoints(Protocol, Str) ->
{Protocol, Endpoint} -> [Endpoint | Acc];
_ -> Acc
end
end, [], string:tokens(Str, ",\n")).
end, [], string:tokens(Str, ",\n ")).

%% @doc Encode primitives.
-spec encode(primitive_type(), kpro:primitive()) -> iodata().
Expand Down
17 changes: 17 additions & 0 deletions test/kpro_lib_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ with_timeout_test_() ->
}
].

parse_endpoints_test_() ->
[ {"empty", ?_assertEqual([], parse(""))}
, {"single", ?_assertEqual([{"127.0.0.1", 1234}], parse("127.0.0.1:1234"))}
, {"comma", ?_assertEqual([{"h1", 1234}, {"h2", 1235}], parse("h1:1234, h2:1235"))}
, {"space", ?_assertEqual([{"host1", 1234}, {"host2", 1235}], parse("host1:1234 host2:1235"))}
, {"plain", ?_assertEqual([{"127.0.0.1", 1234}], parse(plaintext, "plaintext://127.0.0.1:1234"))}
, {"ssl", ?_assertEqual([{"127.0.0.1", 1234}], parse(ssl, "SSL://127.0.0.1:1234"))}
, {"sasl_ssl", ?_assertEqual([{"host", 1234}], parse(sasl_ssl, "SASL_ssl://host:1234\n"))}
, {"sasl_plaintext", ?_assertEqual([{"h", 1234}], parse(sasl_plaintext, "sasl_plaintext://h:1234, "))}
].

parse(Endpoints) ->
kpro_lib:parse_endpoints(undefined, Endpoints).

parse(Proto, Endpoints) ->
kpro_lib:parse_endpoints(Proto, Endpoints).

%%%_* Emacs ====================================================================
%%% Local Variables:
%%% allout-layout: t
Expand Down

0 comments on commit 5d55105

Please sign in to comment.