Skip to content

Commit 20e1194

Browse files
committed
correct typecast incorrectly handling strings starting with digits
1 parent 996c208 commit 20e1194

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/puppet/parser/functions/typecast.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module Puppet::Parser::Functions
3333
when /^[0-9]+\.[0-9]+$/
3434
# found float
3535
arguments[0].to_f
36-
when /^[0-9]+/
36+
when /^[0-9]+$/
3737
# found Fixnum
3838
arguments[0].to_i
3939
else

spec/functions/typecast_spec.rb

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
it "should return strings" do
6666
result = scope.function_typecast(['bob'])
6767
expect(result).to(eq('"bob"'))
68+
69+
result = scope.function_typecast(['4bob'])
70+
expect(result).to(eq('"4bob"'))
6871
end
6972

7073
end

0 commit comments

Comments
 (0)