Skip to content

Commit ad456d6

Browse files
ekohlnofaralfasi
authored andcommitted
Deal with non-strings in is_uuid?
In d971ad5 the method was rewritten with the intention of being compatible with Ruby 3.3 where =~ is only defined on strings. A problem with this is that /regex/.match?(nil) works, but /regex/.match?(42) raises a TypeError. It would have been broken with the old code on Ruby 3.3 as well, but only raised a deprecation warning on prior versions. Fixes: d971ad5 ("Fix warning on nil comparison")
1 parent d971ad5 commit ad456d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/fog/vsphere/compute.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def managed_obj_id(obj)
347347
end
348348

349349
def is_uuid?(id)
350-
/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/.match?(id)
350+
id.is_a?(String) && /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/.match?(id)
351351
end
352352
end
353353

0 commit comments

Comments
 (0)