Skip to content

Commit 517482b

Browse files
committed
Improve DSN parsing and Endpoint building
We can now parse DSN's that have more in the path as just the ID. Also we build the Endpoint again with that path, followed by api/<id>/store. This change brings the DSN parsing and Endpoint building up to par with how the Ruby SDK is doing it. Close #509
1 parent 27f14cf commit 517482b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/sentry/client.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,11 @@ defmodule Sentry.Client do
257257
%URI{userinfo: userinfo, host: host, port: port, path: path, scheme: protocol}
258258
when is_binary(path) and is_binary(userinfo) <- URI.parse(dsn),
259259
[public_key, secret_key] <- keys_from_userinfo(userinfo),
260-
[_, binary_project_id] <- String.split(path, "/"),
260+
uri_path <- String.split(path, "/"),
261+
{binary_project_id, uri_path} <- List.pop_at(uri_path, -1),
262+
base_path <- Enum.join(uri_path, "/"),
261263
{project_id, ""} <- Integer.parse(binary_project_id),
262-
endpoint <- "#{protocol}://#{host}:#{port}/api/#{project_id}/envelope/" do
264+
endpoint <- "#{protocol}://#{host}:#{port}#{base_path}/api/#{project_id}/envelope/" do
263265
{endpoint, public_key, secret_key}
264266
else
265267
_ ->

0 commit comments

Comments
 (0)