src/_Resolve-CciModuleName.ps1
|
function _Resolve-CciModuleName { <# .SYNOPSIS Resolve a user-supplied module name against a v2 tenant feed's prefix. .DESCRIPTION Distribution-v2 feeds serve tenant-prefixed module names (cciit.vmware). This helper lets consumers use natural short or canonical names: vmware -> cciit.vmware (bare short name) Cci.Vmware -> cciit.vmware (canonical name; inner dots stripped, matching the pipeline's stamping rule) cciit.vmware -> cciit.vmware (already prefixed - unchanged) anything-else -> unchanged (explicit names and wildcards pass through) Feeds without a prefix property (v1) always pass names through unchanged. #> [CmdletBinding()] param( [Parameter(Mandatory)] [string]$Name, [Parameter(Mandatory)] [object]$Feed ) $prefixProp = $Feed.PSObject.Properties['prefix'] $prefix = if ($prefixProp) { $prefixProp.Value } if (-not $prefix) { return $Name } if ($Name -match '[\*\?]') { return $Name } if ($Name -like "$prefix.*") { return $Name } if ($Name -match '^Cci\.(?<rest>.+)$') { return "$prefix." + ($Matches['rest'] -replace '\.', '').ToLowerInvariant() } if ($Name -notmatch '\.') { return "$prefix." + $Name.ToLowerInvariant() } $Name } |