Skip to content

Commit fd9be49

Browse files
authored
✨Allow Source to be specified just by hostname (e.g. pwsh.gallery) (#93)
1 parent a72f505 commit fd9be49

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ModuleFast.psm1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,18 @@ function Install-ModuleFast {
254254
)
255255
begin {
256256
trap {$PSCmdlet.ThrowTerminatingError($PSItem)}
257-
258-
259-
260257
#Clear the ModuleFastCache if -Update is specified to ensure fresh lookups of remote module availability
261258
if ($Update) {
262259
Clear-ModuleFastCache
263260
}
264261

262+
#Cleanup that allows for shorthand such as pwsh.gallery
263+
[Uri]$srcTest = $Source
264+
if ($srcTest.Scheme -notin 'http', 'https') {
265+
Write-Debug "Appending https and index.json to $Source"
266+
$Source = "https://$Source/index.json"
267+
}
268+
265269
$defaultRepoPath = $(Join-Path ([Environment]::GetFolderPath('LocalApplicationData')) 'powershell/Modules')
266270
if (-not $Destination) {
267271
#Special function that will retrieve the default module path for the current user
@@ -279,6 +283,8 @@ function Install-ModuleFast {
279283
throw 'Failed to determine destination path. This is a bug, please report it, it should always have something by this point.'
280284
}
281285

286+
287+
282288
# Require approval to create the destination folder if it is not our default path, otherwise this is automatic
283289
if (-not (Test-Path $Destination)) {
284290
if ($configRepoPath -or

0 commit comments

Comments
 (0)