Ensure guest names are string when filtering

Prior to this commit, if a guest name was given as a symbol, the
filter_triggers method would fail to properly match it with the only_on
option, as it is not a valid type to the #String.match method. This
commit fixes that by converting the parameter to a string so that it can
be properly matched on the guest.
This commit is contained in:
Brian Cain 2019-05-13 14:07:22 -07:00
parent 57c4de49f2
commit eb3e309f89
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 2 additions and 2 deletions

View File

@ -110,7 +110,7 @@ module Vagrant
match = false match = false
if trigger.only_on if trigger.only_on
trigger.only_on.each do |o| trigger.only_on.each do |o|
if o.match(guest_name) if o.match(guest_name.to_s)
# trigger matches on current guest, so we're fine to use it # trigger matches on current guest, so we're fine to use it
match = true match = true
break break

View File

@ -74,7 +74,7 @@ describe Vagrant::Plugin::V2::Trigger do
after_triggers = triggers.after_triggers after_triggers = triggers.after_triggers
expect(after_triggers.size).to eq(3) expect(after_triggers.size).to eq(3)
subject.send(:filter_triggers, after_triggers, "ubuntu", :action) subject.send(:filter_triggers, after_triggers, :ubuntu, :action)
expect(after_triggers.size).to eq(2) expect(after_triggers.size).to eq(2)
end end