From 517482bf180efff0b6a4ecebca367187af1a0470 Mon Sep 17 00:00:00 2001 From: Thomas Obernosterer Date: Sat, 28 May 2022 22:23:13 +0200 Subject: [PATCH] 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//store. This change brings the DSN parsing and Endpoint building up to par with how the Ruby SDK is doing it. Close #509 --- lib/sentry/client.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/sentry/client.ex b/lib/sentry/client.ex index 0a002ede..3f838cc4 100644 --- a/lib/sentry/client.ex +++ b/lib/sentry/client.ex @@ -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 _ ->