diff --git a/src/Sentry.Unity.Editor/SentryCli.cs b/src/Sentry.Unity.Editor/SentryCli.cs index 7ca2ad3f2..dd76012c9 100644 --- a/src/Sentry.Unity.Editor/SentryCli.cs +++ b/src/Sentry.Unity.Editor/SentryCli.cs @@ -106,7 +106,7 @@ internal static void AddExecutableToXcodeProject(string projectPath, IDiagnostic internal static string? UrlOverride(string? dsnOption, string? urlOverrideOption) { string? result = urlOverrideOption; - if (result is null && !string.IsNullOrEmpty(dsnOption)) + if (string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(dsnOption)) { var uri = new Uri(dsnOption); @@ -116,7 +116,7 @@ internal static void AddExecutableToXcodeProject(string projectPath, IDiagnostic result = new UriBuilder(uri.Scheme, uri.DnsSafeHost, uri.Port, "").Uri.AbsoluteUri.TrimEnd('/'); } } - return result; + return string.IsNullOrEmpty(result) ? null : result; } } } diff --git a/test/Sentry.Unity.Editor.Tests/SentryCliTests.cs b/test/Sentry.Unity.Editor.Tests/SentryCliTests.cs index f3f04db36..d1d347f6b 100644 --- a/test/Sentry.Unity.Editor.Tests/SentryCliTests.cs +++ b/test/Sentry.Unity.Editor.Tests/SentryCliTests.cs @@ -129,6 +129,9 @@ public void AddExecutableToXcodeProject_ExecutableAlreadyExists_LogsAndReturns() public void UrlOverride() { Assert.IsNull(SentryCli.UrlOverride(null, null)); + Assert.IsNull(SentryCli.UrlOverride("", null)); + Assert.IsNull(SentryCli.UrlOverride(null, "")); + Assert.IsNull(SentryCli.UrlOverride("", "")); Assert.IsNull(SentryCli.UrlOverride("https://key@o447951.ingest.sentry.io/5439417", null)); Assert.IsNull(SentryCli.UrlOverride("https://foo.sentry.io/5439417", null)); Assert.IsNull(SentryCli.UrlOverride("http://sentry.io", null));