Skip to content

Commit

Permalink
Merge pull request #507 from AtjonTV/506-improve-dsn-parsing
Browse files Browse the repository at this point in the history
Improve DSN parsing and Endpoint building
  • Loading branch information
mitchellhenke authored May 29, 2022
2 parents 27f14cf + 517482b commit 76b23db
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/sentry/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,11 @@ defmodule Sentry.Client do
%URI{userinfo: userinfo, host: host, port: port, path: path, scheme: protocol}
when is_binary(path) and is_binary(userinfo) <- URI.parse(dsn),
[public_key, secret_key] <- keys_from_userinfo(userinfo),
[_, binary_project_id] <- String.split(path, "/"),
uri_path <- String.split(path, "/"),
{binary_project_id, uri_path} <- List.pop_at(uri_path, -1),
base_path <- Enum.join(uri_path, "/"),
{project_id, ""} <- Integer.parse(binary_project_id),
endpoint <- "#{protocol}://#{host}:#{port}/api/#{project_id}/envelope/" do
endpoint <- "#{protocol}://#{host}:#{port}#{base_path}/api/#{project_id}/envelope/" do
{endpoint, public_key, secret_key}
else
_ ->
Expand Down

0 comments on commit 76b23db

Please sign in to comment.