Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#18) Use more versatile URL handling for getting the chocolatey install script URL #38

Merged
merged 3 commits into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.EndsWith(".ps1")) {
if ($source -like "*.ps1") {
$script_url = $source
} 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