Skip to content

Commit

Permalink
Support querystring parameters on the dsn (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbed authored and martinklepsch committed Mar 16, 2019
1 parent 821b297 commit 4109bd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/raven_clj/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions test/raven_clj/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4109bd8

Please sign in to comment.