Skip to content

Commit

Permalink
Bug fix for non-PSGallery repos adding script endpoint (#1526)
Browse files Browse the repository at this point in the history
  • Loading branch information
alerickson authored Jan 22, 2024
1 parent d0bf74e commit 132cf65
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/code/V2ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal class V2ServerAPICalls : ServerApiCall
public FindResponseType v2FindResponseType = FindResponseType.ResponseString;
private bool _isADORepo;
private bool _isJFrogRepo;
private bool _isPSGalleryRepo;

#endregion

Expand All @@ -60,6 +61,7 @@ public V2ServerAPICalls (PSRepositoryInfo repository, PSCmdlet cmdletPassedIn, N
var repoURL = repository.Uri.ToString().ToLower();
_isADORepo = repoURL.Contains("pkgs.dev.azure.com") || repoURL.Contains("pkgs.visualstudio.com");
_isJFrogRepo = repoURL.Contains("jfrog");
_isPSGalleryRepo = repoURL.Contains("powershellgallery.com/api/v2");
}

#endregion
Expand Down Expand Up @@ -806,7 +808,7 @@ private HttpContent HttpRequestCallForContent(string requestUrlV2, out ErrorReco
private string FindAllFromTypeEndPoint(bool includePrerelease, bool isSearchingModule, int skip, out ErrorRecord errRecord)
{
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::FindAllFromTypeEndPoint()");
string typeEndpoint = isSearchingModule ? String.Empty : "/items/psscript";
string typeEndpoint = _isPSGalleryRepo && !isSearchingModule ? "/items/psscript" : String.Empty;
string paginationParam = $"&$orderby=Id desc&$inlinecount=allpages&$skip={skip}&$top=6000";
var prereleaseFilter = includePrerelease ? "IsAbsoluteLatestVersion&includePrerelease=true" : "IsLatestVersion";

Expand All @@ -826,7 +828,7 @@ private string FindTagFromEndpoint(string[] tags, bool includePrerelease, bool i
// type: S -> just search Scripts end point
// type: DSCResource -> just search Modules
// type: Command -> just search Modules
string typeEndpoint = isSearchingModule ? String.Empty : "/items/psscript";
string typeEndpoint = _isPSGalleryRepo && !isSearchingModule ? "/items/psscript" : String.Empty;
string paginationParam = $"&$orderby=Id desc&$inlinecount=allpages&$skip={skip}&$top=6000";
var prereleaseFilter = includePrerelease ? "includePrerelease=true&$filter=IsAbsoluteLatestVersion" : "$filter=IsLatestVersion";
string typeFilterPart = isSearchingModule ? $" and substringof('PSModule', Tags) eq true" : $" and substringof('PSScript', Tags) eq true";
Expand Down

0 comments on commit 132cf65

Please sign in to comment.