Skip to content

Commit ace9e82

Browse files
committed
Merge pull request #37 from sliim-cookbooks/fix-hostname-config-option
Fix/Adapt regex for HostName option when parsing file
2 parents ecfad2f + c8dfdfa commit ace9e82

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

libraries/ssh_config_helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def parse_file(path)
1919
IO.foreach(path) do |line|
2020
next if line.match(/^\s*(#|\r?\n|\s*$)/) # skip lines with only comments or whitespace
2121

22-
matchdata = line.match(/^\s*([h|H]ost)(.*$)/)
22+
matchdata = line.match(/^\s*([h|H]ost\s+)(.*$)/)
2323
if matchdata
2424
name = matchdata.captures[1].strip
2525
entries[name] = {}

spec/provider_tests/config_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
content << 'and_also_with=equal sign'
2222
content << 'Host second with extra patterns'
2323
content << ' Extra_spaces did_not_matter'
24+
content << ' HostName option is correctly matched'
2425
content << ' Multiple_words not a problem'
2526
content << ' We "can handle quotes"'
2627
end
@@ -39,6 +40,7 @@
3940
content << ''
4041
content << 'Host second with extra patterns'
4142
content << ' Extra_spaces did_not_matter'
43+
content << ' HostName option is correctly matched'
4244
content << ' Multiple_words not a problem'
4345
content << ' We "can handle quotes"'
4446
content << ''

0 commit comments

Comments
 (0)