Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Fix UriFormatException (#921)
Browse files Browse the repository at this point in the history
* Fix UriFormatException

Fix UriFormatException with message "Invalid URI: Invalid port specified." when Username contains '@'

* Handle null username

Co-authored-by: Stuart Lang <[email protected]>
  • Loading branch information
Skotina and slang25 authored Feb 17, 2020
1 parent f6d9a82 commit 7f8fa17
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NuKeeper.Git/GitCmdDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ private async Task<string> StartGitProzess(string arguments, bool ensureSuccess

private Uri CreateCredentialsUri(Uri pullEndpoint, GitUsernamePasswordCredentials gitCredentials)
{
if (_gitCredentials == null)
if (_gitCredentials?.Username == null)
{
return pullEndpoint;
}

return new UriBuilder(pullEndpoint) { UserName = gitCredentials.Username, Password = gitCredentials.Password }.Uri;
return new UriBuilder(pullEndpoint) { UserName = Uri.EscapeDataString(gitCredentials.Username), Password = gitCredentials.Password }.Uri;
}
}
}

0 comments on commit 7f8fa17

Please sign in to comment.