Skip to content

Commit

Permalink
Merge pull request #44 from rodjek/facterdb-148
Browse files Browse the repository at this point in the history
Escape period in JGrep.format float regex
  • Loading branch information
ploubser committed Feb 28, 2020
2 parents de89686 + 537a1bf commit 5d6d105
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jgrep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def self.validate_filters(filters)
def self.format(kvalue, value)
if kvalue.to_s =~ /^\d+$/ && value.to_s =~ /^\d+$/
[Integer(kvalue), Integer(value)]
elsif kvalue.to_s =~ /^\d+.\d+$/ && value.to_s =~ /^\d+.\d+$/
elsif kvalue.to_s =~ /^\d+\.\d+$/ && value.to_s =~ /^\d+\.\d+$/
[Float(kvalue), Float(value)]
else
[kvalue, value]
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/jgrep_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ module JGrep
expect(result1.is_a?(String)).to eq(true)
expect(result2.is_a?(String)).to eq(true)
end

it 'should not format strings with a single [^\d\.] character' do
result1, result2 = JGrep.format("2012R2", "2008R2")
expect(result1).to be_a(String)
expect(result2).to be_a(String)
end
end

describe "#has_object?" do
Expand Down

0 comments on commit 5d6d105

Please sign in to comment.