diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c08d55ab..beddb1ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Current +- Fix parsing multiple delimeters in the amount, after BigDecimal updates + ## 1.13.0 - **Breaking change**: check ISO currency code validity when parsing strings with `to_money` - Adds `expect_whole_subunits` option when fractional subunits are expected diff --git a/Gemfile b/Gemfile index c496b3645..14dee0295 100644 --- a/Gemfile +++ b/Gemfile @@ -10,4 +10,8 @@ elsif RUBY_VERSION =~ /^1/ gem 'i18n', '~> 0.9' end +if RUBY_VERSION >= '3.4.0' + gem 'bigdecimal' +end + gemspec diff --git a/lib/monetize/parser.rb b/lib/monetize/parser.rb index 8d88c09a6..79f2645ec 100644 --- a/lib/monetize/parser.rb +++ b/lib/monetize/parser.rb @@ -184,8 +184,10 @@ def regex_safe_symbols end def split_major_minor(num, delimiter) - major, minor = num.split(delimiter) - [major, minor || '00'] + splits = num.split(delimiter) + fail ParseError, 'Invalid amount (multiple delimiters)' if splits.length > 2 + + [splits[0], splits[1] || '00'] end def currency_symbol_regex