diff --git a/CHANGELOG.md b/CHANGELOG.md index ebc88e9..8840145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Babashka [http-client](https://github.com/babashka/http-client): HTTP client for - [#71](https://github.com/babashka/http-client/issues/71): Link back to sources in release artifact ([@lread](https://github.com/lread)) +- [#73](https://github.com/babashka/http-client/issues/71): Allow implicit ports when specifying the URL as a map ([@lvh](https://github.com/lvh)) ## 0.4.21 (2024-09-10) diff --git a/src/babashka/http_client/internal/helpers.clj b/src/babashka/http_client/internal/helpers.clj index ab2b467..e899182 100644 --- a/src/babashka/http_client/internal/helpers.clj +++ b/src/babashka/http_client/internal/helpers.clj @@ -8,7 +8,7 @@ (java.net.URI. ^String (:scheme uri) ^String (:user uri) ^String (:host uri) - ^Integer (:port uri) + ^Integer (:port uri -1) ^String (:path uri) ^String (:query uri) ^String (:fragment uri)) diff --git a/test/babashka/http_client/internal/helpers_test.clj b/test/babashka/http_client/internal/helpers_test.clj new file mode 100644 index 0000000..ef03e82 --- /dev/null +++ b/test/babashka/http_client/internal/helpers_test.clj @@ -0,0 +1,8 @@ +(ns babashka.http-client.internal.helpers-test + (:require + [babashka.http-client.internal.helpers :as h] + [clojure.test :as t])) + +(t/deftest ->uri-tests + (let [uri (h/->uri {:scheme "https" :host "example.com" :path "/foo"})] + (t/is (= (.getPort uri) -1))))