fix regex

Fixing a bug where the script deleted commented lines in the hosts file (Thanks Bec-de-Xorbin)
This commit is contained in:
amd64fox
2022-07-21 09:22:41 +03:00
parent a02860d3dd
commit 96ceebda0c

View File

@@ -550,11 +550,11 @@ $testHosts = Test-Path -Path $pathHosts
if ($testHosts) {
$hosts = Get-Content -Path $pathHosts
if ($hosts -match '.+scdn.+' -or $hosts -match '.+spotify.+' ) {
if ($hosts -match '^[^\#| ].+scdn.+|^[^\#].+spotify.+') {
Write-Host ($lang).HostDel`n
try {
$hosts = $hosts -replace '.+scdn.+', '' -replace '.+spotify.+', ''
$hosts = $hosts -replace '^[^\#| ].+scdn.+|^[^\#| ].+spotify.+', ''
Set-Content -Path $pathHosts -Value $hosts -Force
$hosts | Where-Object { $_.trim() -ne "" } | Set-Content -Path $pathHosts -Force
}