From 730a3c84554a72603362d57b1fa09e93c935eb23 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Feb 2025 21:12:18 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20[Cleanup]:=20Remove?= =?UTF-8?q?=20`ConvertTo-QueryString`=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utilities/Web/ConvertTo-QueryString.ps1 | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/functions/private/Utilities/Web/ConvertTo-QueryString.ps1 diff --git a/src/functions/private/Utilities/Web/ConvertTo-QueryString.ps1 b/src/functions/private/Utilities/Web/ConvertTo-QueryString.ps1 deleted file mode 100644 index 6fce4ecba..000000000 --- a/src/functions/private/Utilities/Web/ConvertTo-QueryString.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -filter ConvertTo-QueryString { - <# - .SYNOPSIS - Convert an object to a query string - - .DESCRIPTION - Convert an object to a query string - - .EXAMPLE - ConvertTo-QueryString -InputObject @{a=1;b=2} - - ?a=1&b=2 - - .EXAMPLE - ConvertTo-QueryString -InputObject @{a='this is value of a';b='valueOfB'} - - ?a=this%20is%20value%20of%20a&b=valueOfB - - .EXAMPLE - ConvertTo-QueryString -InputObject @{a='this is value of a';b='valueOfB'} -AsURLEncoded - - ?a=this+is+value+of+a&b=valueOfB - #> - [OutputType([string])] - [CmdletBinding()] - param( - [Parameter( - Mandatory, - ValueFromPipeline - )] - [object] $InputObject, - - [Parameter()] - [switch] $AsURLEncoded - ) - - if ($InputObject -isnot [hashtable]) { - $InputObject = $InputObject | ConvertTo-HashTable - } - - $parameters = if ($AsURLEncoded) { - ($InputObject.GetEnumerator() | ForEach-Object { - "$([System.Web.HttpUtility]::UrlEncode($_.Key))=$([System.Web.HttpUtility]::UrlEncode($_.Value))" - }) -join '&' - } else { - ($InputObject.GetEnumerator() | ForEach-Object { - "$([System.Uri]::EscapeDataString($_.Key))=$([System.Uri]::EscapeDataString($_.Value))" - }) -join '&' - } - - if ($parameters) { - '?' + $parameters - } -} From 14b48d6f659c004ac854efbe9d2bc3831b32ad22 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Feb 2025 21:13:34 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20`Invoke-?= =?UTF-8?q?GitHubAPI`=20to=20require=20`Web`=20module=20and=20change=20que?= =?UTF-8?q?ry=20string=20conversion=20to=20`ConvertTo-WebQueryString`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/API/Invoke-GitHubAPI.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index 9f3ac0f34..78a6d58fb 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -1,4 +1,6 @@ -filter Invoke-GitHubAPI { +#Requires -Modules @{ ModuleName = 'Web'; RequiredVersion = '1.0.0' } + +filter Invoke-GitHubAPI { <# .SYNOPSIS Calls the GitHub API using the provided parameters. @@ -160,7 +162,7 @@ Write-Debug "Setting per_page to the default value in context [$($Context.PerPage)]." $Body['per_page'] = $Context.PerPage } - $queryString = $Body | ConvertTo-QueryString + $queryString = $Body | ConvertTo-WebQueryString $APICall.Uri = $APICall.Uri + $queryString } elseif ($Body -is [string]) { # Use body to create the form data