From dde7c097ea5b8ce1a2ec5a3dafdf95b66bbdc5a5 Mon Sep 17 00:00:00 2001 From: Joel Sallow <32407840+vexx32@users.noreply.github.com> Date: Thu, 8 Apr 2021 09:42:25 -0400 Subject: [PATCH] :sparkles: (#18) Improve install source url handling --- chocolatey/plugins/modules/win_chocolatey.ps1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/chocolatey/plugins/modules/win_chocolatey.ps1 b/chocolatey/plugins/modules/win_chocolatey.ps1 index aff265c..d27cd56 100644 --- a/chocolatey/plugins/modules/win_chocolatey.ps1 +++ b/chocolatey/plugins/modules/win_chocolatey.ps1 @@ -248,17 +248,20 @@ Function Install-Chocolatey { } if ($source) { + $uri_info = [System.Uri]$source + # check if the URL already contains the path to PS script if ($source -like "*.ps1") { $script_url = $source - } else { + } elseif ($uri_info.AbsolutePath -like '/repository/*') { + $script_url = "$($uri_info.Scheme)://$($uri_info.Authority)/$($uri_info.AbsolutePath)/install.ps1" -replace '//','/' + }else { # chocolatey server automatically serves a script at # http://host/install.ps1, we rely on this behaviour when a - # user specifies the choco source URL. If a custom URL or file - # path is desired, they should use win_get_url/win_shell - # manually - # we need to strip the path off the URL and append install.ps1 - $uri_info = [System.Uri]$source + # user specifies the choco source URL and it doesn't look like a repository style url. + # If a custom URL or file path is desired, they should use win_get_url/win_shell + # manually. + # We need to strip the path off the URL and append install.ps1 $script_url = "$($uri_info.Scheme)://$($uri_info.Authority)/install.ps1" } if ($source_username) {