diff --git a/src/code/V2ServerAPICalls.cs b/src/code/V2ServerAPICalls.cs index c690c48ae..5017d13da 100644 --- a/src/code/V2ServerAPICalls.cs +++ b/src/code/V2ServerAPICalls.cs @@ -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 @@ -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) { @@ -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)