Skip to content

Commit

Permalink
Reduced code complexity in ReadHostsFile() private method of the Host…
Browse files Browse the repository at this point in the history
…sFileManager class.
  • Loading branch information
xvitaly committed Mar 17, 2024
1 parent 829cc00 commit 94a0fe4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/mhlib/HostsFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ private async Task ReadHostsFile(string SourceFile)
while (OpenedHosts.Peek() >= 0)
{
string ImpStr = StringsManager.CleanString(await OpenedHosts.ReadLineAsync());
if (HostsFileEntryParser.TryParse(ImpStr, out HostsFileEntryParser Parser))
if (HostsFileEntryParser.TryParse(ImpStr, out HostsFileEntryParser Parser) && IPAddress.TryParse(Parser.IP, out IPAddress IP) && Hostname.TryParse(Parser.Host, out Hostname Host))
{
if (IPAddress.TryParse(Parser.IP, out IPAddress IP) && Hostname.TryParse(Parser.Host, out Hostname Host))
{
Contents.Add(new HostsFileEntry(IP, Host, Parser.Comment));
}
Contents.Add(new HostsFileEntry(IP, Host, Parser.Comment));
}
}
}
Expand Down

0 comments on commit 94a0fe4

Please sign in to comment.