diff --git a/changelog.md b/changelog.md index 6fe08e8..f43bded 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/src/kpro_lib.erl b/src/kpro_lib.erl index c5fb06a..6a6ffa0 100644 --- a/src/kpro_lib.erl +++ b/src/kpro_lib.erl @@ -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(). diff --git a/test/kpro_lib_tests.erl b/test/kpro_lib_tests.erl index b1950c3..00350ed 100644 --- a/test/kpro_lib_tests.erl +++ b/test/kpro_lib_tests.erl @@ -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