Skip to content

Commit 9ca58c3

Browse files
committed
Bug fix for non-PSGallery repos adding script endpoint (#1526)
1 parent 2edd555 commit 9ca58c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/code/V2ServerAPICalls.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ internal class V2ServerAPICalls : ServerApiCall
4141
public FindResponseType v2FindResponseType = FindResponseType.ResponseString;
4242
private bool _isADORepo;
4343
private bool _isJFrogRepo;
44+
private bool _isPSGalleryRepo;
4445

4546
#endregion
4647

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

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

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

0 commit comments

Comments
 (0)