Skip to content

Commit 00a3b85

Browse files
Normalize DSN URI. (getsentry#1032)
1 parent 4b8b7d7 commit 00a3b85

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# vNext
22

33
* Increase max cached events to 30 (#1029)
4+
* Normalize DSN URI (#1030)
45

56
# 3.1.2
67

sentry/src/main/java/io/sentry/Dsn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ URI getSentryUri() {
4747

4848
Dsn(@Nullable String dsn) throws InvalidDsnException {
4949
try {
50-
URI uri = new URI(dsn);
50+
URI uri = new URI(dsn).normalize();
5151
String userInfo = uri.getUserInfo();
5252
if (userInfo == null || userInfo.isEmpty()) {
5353
throw new IllegalArgumentException("Invalid DSN: No public key provided.");

sentry/src/test/java/io/sentry/DsnTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,10 @@ class DsnTest {
7373
val ex = assertFailsWith<InvalidDsnException> { Dsn("https://:secret@host/path/id") }
7474
assertEquals("java.lang.IllegalArgumentException: Invalid DSN: No public key provided.", ex.message)
7575
}
76+
77+
@Test
78+
fun `dsn is normalized`() {
79+
val dsn = Dsn("http://key@host//id")
80+
assertEquals("http://host/api/id", dsn.sentryUri.toURL().toString())
81+
}
7682
}

0 commit comments

Comments
 (0)