Skip to content

Commit

Permalink
Remove leading slash from relative Uri endpoints when constructing fu…
Browse files Browse the repository at this point in the history
…ll Uri
  • Loading branch information
ryangribble committed Mar 22, 2016
1 parent 96d8777 commit 44df426
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Octokit/Http/HttpClientAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ protected virtual HttpRequestMessage BuildRequestMessage(IRequest request)
HttpRequestMessage requestMessage = null;
try
{
var fullUri = new Uri(request.BaseAddress, request.Endpoint);
// Remove any leading slash from endpoint Uri (otherwise it clobbers the /api/v3/ in BaseAddress)
var endpoint = request.Endpoint;
if (!endpoint.IsAbsoluteUri &&
endpoint.ToString().StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
endpoint = new Uri(endpoint.ToString().TrimStart('/'), UriKind.Relative);
}

var fullUri = new Uri(request.BaseAddress, endpoint);
requestMessage = new HttpRequestMessage(request.Method, fullUri);

foreach (var header in request.Headers)
Expand Down

0 comments on commit 44df426

Please sign in to comment.