-
-
Notifications
You must be signed in to change notification settings - Fork 468
Expand file tree
/
Copy pathDsnUtil.java
More file actions
43 lines (34 loc) · 1.08 KB
/
DsnUtil.java
File metadata and controls
43 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package io.sentry;
import java.net.URI;
import java.util.Locale;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ApiStatus.Internal
public final class DsnUtil {
public static boolean urlContainsDsnHost(@Nullable SentryOptions options, @Nullable String url) {
if (options == null) {
return false;
}
if (url == null) {
return false;
}
final @Nullable String dsnString = options.getDsn();
if (dsnString == null) {
return false;
}
final @NotNull Dsn dsn = options.retrieveParsedDsn();
final @NotNull URI sentryUri = dsn.getSentryUri();
final @Nullable String dsnHost = sentryUri.getHost();
if (dsnHost == null) {
return false;
}
final @NotNull String lowerCaseHost = dsnHost.toLowerCase(Locale.ROOT);
final int dsnPort = sentryUri.getPort();
if (dsnPort > 0) {
return url.toLowerCase(Locale.ROOT).contains(lowerCaseHost + ":" + dsnPort);
} else {
return url.toLowerCase(Locale.ROOT).contains(lowerCaseHost);
}
}
}