Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 334fa1b

Browse files
Correcting logic to find the host
1 parent c312a99 commit 334fa1b

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ private AuthenticationService AuthenticationService
3434
{
3535
if (authenticationService == null)
3636
{
37-
var host = Repository != null
38-
? new UriString(Repository.CloneUrl.ToRepositoryUri().GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped))
39-
: UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
37+
UriString host;
38+
if (Repository != null && Repository.CloneUrl != null && Repository.CloneUrl.IsValidUri)
39+
{
40+
host = new UriString(Repository.CloneUrl.ToRepositoryUri()
41+
.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped));
42+
}
43+
else
44+
{
45+
host = UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
46+
}
4047

4148
AuthenticationService = new AuthenticationService(host, new AppConfiguration(), Platform.Keychain);
4249
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/Window.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,16 @@ private void GoToProfile(object obj)
223223
}
224224
private void SignOut(object obj)
225225
{
226-
var host = Repository != null
227-
? new UriString(Repository.CloneUrl.ToRepositoryUri().GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped))
228-
: UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
226+
UriString host;
227+
if (Repository != null && Repository.CloneUrl != null && Repository.CloneUrl.IsValidUri)
228+
{
229+
host = new UriString(Repository.CloneUrl.ToRepositoryUri()
230+
.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped));
231+
}
232+
else
233+
{
234+
host = UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
235+
}
229236

230237
var apiClient = ApiClient.Create(host, Platform.Keychain, new AppConfiguration());
231238
apiClient.Logout(host);

0 commit comments

Comments
 (0)