Explorar o código

fix(webhook-action): fix webhook action path type error

Turtle %!s(int64=4) %!d(string=hai) anos
pai
achega
e0336e60da
Modificáronse 1 ficheiros con 7 adicións e 4 borrados
  1. 7 4
      apps/emqx_web_hook/src/emqx_web_hook_actions.erl

+ 7 - 4
apps/emqx_web_hook/src/emqx_web_hook_actions.erl

@@ -314,14 +314,15 @@ ensure_content_type_header(Headers, _Method) ->
     lists:keydelete("content-type", 1, Headers).
 
 merge_path(CommonPath, <<>>) ->
-    CommonPath;
+    l2b(CommonPath);
 merge_path(CommonPath, Path0) ->
     case emqx_http_lib:uri_parse(Path0) of
-        {ok, #{path := Path1, 'query' := Query}} ->
-            Path2 = filename:join(CommonPath, Path1),
+        {ok, #{path := Path1, 'query' := Query0}} ->
+            Path2 = l2b(filename:join(CommonPath, Path1)),
+            Query = l2b(Query0),
             <<Path2/binary, "?", Query/binary>>;
         {ok, #{path := Path1}} ->
-            filename:join(CommonPath, Path1)
+            l2b(filename:join(CommonPath, Path1))
     end.
 
 method(GET) when GET == <<"GET">>; GET == <<"get">> -> get;
@@ -386,3 +387,5 @@ test_http_connect(Conf) ->
            ?LOG(error, "check http_connectivity failed: ~p, ~0p", [Conf, {Err, Reason, ST}]),
            false
     end.
+l2b(L) when is_list(L) -> iolist_to_binary(L);
+l2b(Any) -> Any.