Skip to content

Commit

Permalink
Merge pull request #275 from ftes/fix/parse-db-url-with-encoded-hash
Browse files Browse the repository at this point in the history
Fix: Parse url with encoded hash in password
  • Loading branch information
slashdotdash committed Oct 18, 2023
2 parents a300b3b + 5c52acd commit a862d02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/event_store/config/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule EventStore.Config.Parser do
defp parse_url(""), do: []

defp parse_url(url) do
info = url |> URI.decode() |> URI.parse()
info = URI.parse(url)

if is_nil(info.host) do
raise ArgumentError, message: "host is not present"
Expand Down
16 changes: 16 additions & 0 deletions test/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ defmodule EventStore.ConfigTest do
)
end

test "parse url with encoded hash in password" do
config = [url: "postgres://username:password%23with_hash@localhost/database"]

assert_parsed_config(config,
enable_hard_deletes: false,
column_data_type: "bytea",
schema: "public",
timeout: 15_000,
pool: EventStore.Config.get_pool(),
username: "username",
password: "password#with_hash",
database: "database",
hostname: "localhost"
)
end

test "parse session_mode_url" do
config = [session_mode_url: "postgres://username:password@localhost/database"]

Expand Down

0 comments on commit a862d02

Please sign in to comment.