Private/ConvertTo-DirFolder.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function ConvertTo-DirFolder {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$DirectoryUrl
    )

    # strip the http prefix and replace port-related colon with underscore
    $dirFolder = $DirectoryUrl.Replace('https://','').Replace(':','_')

    # strip everything following the hostname and add the config root
    $dirFolder = Join-Path (Get-ConfigRoot) $dirFolder.Substring(0,$dirFolder.IndexOf('/'))

    return $dirFolder
}