We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c4f2b9e + d9e96f9 commit 2476ce5Copy full SHA for 2476ce5
modules/post/windows/manage/remove_host.rb
@@ -59,7 +59,15 @@ def run
59
fdray = fd.read.split("\r\n")
60
61
fdray.each do |line|
62
- unless line.match("\t#{hosttoremove}$")
+ main_part = line.split('#', 2).first.to_s.strip
63
+ parts = main_part.split(/\s+/)
64
+ if parts[1..-1].to_a.include?(hosttoremove)
65
+ parts.delete_if { |p| p.casecmp(hosttoremove).zero? }
66
+ next if parts.size < 2
67
+ rebuilt = parts.join(' ')
68
+ rebuilt += " " + line.split('#', 2).last if line.include?('#')
69
+ newfile += "#{rebuilt}\r\n"
70
+ else
71
newfile += "#{line}\r\n"
72
end
73
0 commit comments