Skip to content

Commit 132cf65

Browse files
authored
Bug fix for non-PSGallery repos adding script endpoint (#1526)
1 parent d0bf74e commit 132cf65

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
@@ -806,7 +808,7 @@ private HttpContent HttpRequestCallForContent(string requestUrlV2, out ErrorReco
806808
private string FindAllFromTypeEndPoint(bool includePrerelease, bool isSearchingModule, int skip, out ErrorRecord errRecord)
807809
{
808810
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::FindAllFromTypeEndPoint()");
809-
string typeEndpoint = isSearchingModule ? String.Empty : "/items/psscript";
811+
string typeEndpoint = _isPSGalleryRepo && !isSearchingModule ? "/items/psscript" : String.Empty;
810812
string paginationParam = $"&$orderby=Id desc&$inlinecount=allpages&$skip={skip}&$top=6000";
811813
var prereleaseFilter = includePrerelease ? "IsAbsoluteLatestVersion&includePrerelease=true" : "IsLatestVersion";
812814

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

0 commit comments

Comments
 (0)