Private/Save-SshImportIdCustomSourceMap.ps1

function Save-SshImportIdCustomSourceMap {
    <#
    .SYNOPSIS
        Persists the custom-source prefix -> URL template map to disk.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [hashtable] $Map
    )

    $path = Get-SshImportIdConfigPath
    $dir = Split-Path -Parent $path
    if (-not (Test-Path -Path $dir)) {
        New-Item -ItemType Directory -Path $dir -Force | Out-Null
    }

    $lines = @('@{', ' Sources = @{')
    foreach ($key in $Map.Keys) {
        $escaped = $Map[$key] -replace "'", "''"
        $lines += " '$key' = '$escaped'"
    }
    $lines += ' }'
    $lines += '}'

    Set-Content -Path $path -Value ($lines -join [Environment]::NewLine) -Encoding utf8
}