Skip to content

Commit

Permalink
✨ (#18) Improve install source url handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vexx32 committed Apr 8, 2021
1 parent bd794b7 commit dde7c09
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions chocolatey/plugins/modules/win_chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dde7c09

Please sign in to comment.