From 96ceebda0cd4b0720b3fe5d4fbba6b07e7f69ebf Mon Sep 17 00:00:00 2001 From: amd64fox Date: Thu, 21 Jul 2022 09:22:41 +0300 Subject: [PATCH] fix regex Fixing a bug where the script deleted commented lines in the hosts file (Thanks Bec-de-Xorbin) --- Install.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Install.ps1 b/Install.ps1 index 107fe7e..166a27f 100644 --- a/Install.ps1 +++ b/Install.ps1 @@ -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 }