Skip to content

Commit

Permalink
Change syntax to be accommodating for subsequent PR
Browse files Browse the repository at this point in the history
  • Loading branch information
alerickson committed Oct 2, 2023
1 parent ea3deae commit f73f956
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/code/V2ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public V2ServerAPICalls (PSRepositoryInfo repository, PSCmdlet cmdletPassedIn, N

_sessionClient = new HttpClient(handler);
_sessionClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", userAgentString);
_isJFrogRepo = repository.Uri.ToString().ToLower().Contains("jfrog");
var repoURL = repository.Uri.ToString().ToLower();
_isJFrogRepo = repoURL.Contains("jfrog");
}

#endregion
Expand Down Expand Up @@ -671,7 +672,16 @@ public override FindResults FindVersionWithTag(string packageName, string versio
public override Stream InstallName(string packageName, string packageVersion, bool includePrerelease, out ErrorRecord errRecord)
{
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::InstallName()");
var requestUrlV2 = _isJFrogRepo ? $"{Repository.Uri}/Download/{packageName}/{packageVersion}" : $"{Repository.Uri}/package/{packageName}";
var requestUrlV2 = string.Empty;

if (_isJFrogRepo)
{
requestUrlV2 = $"{Repository.Uri}/Download/{packageName}/{packageVersion}";
}
else {
requestUrlV2 = $"{Repository.Uri}/package/{packageName}";
}

var response = HttpRequestCallForContent(requestUrlV2, out errRecord);
if (errRecord != null)
{
Expand All @@ -694,8 +704,16 @@ public override Stream InstallName(string packageName, string packageVersion, bo
public override Stream InstallVersion(string packageName, string version, out ErrorRecord errRecord)
{
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::InstallVersion()");
var downloadType = _isJFrogRepo ? "Download" : "package";
var requestUrlV2 = $"{Repository.Uri}/{downloadType}/{packageName}/{version}";
var requestUrlV2 = string.Empty;

if (_isJFrogRepo)
{
requestUrlV2 = $"{Repository.Uri}/Download/{packageName}/{version}";
}
else {
requestUrlV2 = $"{Repository.Uri}/package/{packageName}/{version}";
}

var response = HttpRequestCallForContent(requestUrlV2, out errRecord);
var responseStream = response.ReadAsStreamAsync().Result;
if (errRecord != null)
Expand Down

0 comments on commit f73f956

Please sign in to comment.