diff --git a/src/raven_clj/core.clj b/src/raven_clj/core.clj index c78a8f1..c5f14b2 100644 --- a/src/raven_clj/core.clj +++ b/src/raven_clj/core.clj @@ -52,7 +52,11 @@ :uri (format "%s://%s" protocol (string/join "/" (butlast (string/split url #"/")))) - :project-id (Integer/parseInt (last (string/split url #"/")))})) + :project-id (-> (string/split url #"/") + (last) + (string/split #"\?") + (first) + (Integer/parseInt))})) (defn capture "Send a message to a Sentry server. diff --git a/test/raven_clj/core_test.clj b/test/raven_clj/core_test.clj index 261ab3e..e43c7fd 100644 --- a/test/raven_clj/core_test.clj +++ b/test/raven_clj/core_test.clj @@ -78,6 +78,13 @@ (testing "dsn parsing with port and path" (is (= (parse-dsn "https://b70a31b3510c4cf793964a185cfe1fd0:b7d80b520139450f903720eb7991bf3d@example.com:9000/sentry/1") + {:key "b70a31b3510c4cf793964a185cfe1fd0" + :secret "b7d80b520139450f903720eb7991bf3d" + :uri "https://example.com:9000/sentry" + :project-id 1}))) + + (testing "dsn parsing with query parameters" + (is (= (parse-dsn "https://b70a31b3510c4cf793964a185cfe1fd0:b7d80b520139450f903720eb7991bf3d@example.com:9000/sentry/1?environment=test&servername=example") {:key "b70a31b3510c4cf793964a185cfe1fd0" :secret "b7d80b520139450f903720eb7991bf3d" :uri "https://example.com:9000/sentry"