diff --git a/CHANGELOG.md b/CHANGELOG.md index db575cf..07243c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.17 - September 17, 2018 + +- Do not crash when given too short account numbers for New Zealand + ## 0.11.16 - September 3, 2018 - Loosen `i18n` dependency (thanks @glaszig!) diff --git a/lib/ibandit/local_details_cleaner.rb b/lib/ibandit/local_details_cleaner.rb index 0e8a436..929bada 100644 --- a/lib/ibandit/local_details_cleaner.rb +++ b/lib/ibandit/local_details_cleaner.rb @@ -455,7 +455,7 @@ def self.clean_nz_details(local_details) account_number = cleaned_account_number[6..-1] end - if account_number.length == 9 + if account_number && account_number.length == 9 # > Some banks (such as BNZ) include three digits of the suffix in their # > presentation of the account number to the end customer. Other banks # > only show the last two digits of the suffix to the end customer. diff --git a/lib/ibandit/version.rb b/lib/ibandit/version.rb index c2b1fa5..ec1bf54 100644 --- a/lib/ibandit/version.rb +++ b/lib/ibandit/version.rb @@ -1,3 +1,3 @@ module Ibandit - VERSION = "0.11.16".freeze + VERSION = "0.11.17".freeze end diff --git a/spec/ibandit/local_details_cleaner_spec.rb b/spec/ibandit/local_details_cleaner_spec.rb index e84d600..c0caeda 100644 --- a/spec/ibandit/local_details_cleaner_spec.rb +++ b/spec/ibandit/local_details_cleaner_spec.rb @@ -956,6 +956,11 @@ its([:branch_code]) { is_expected.to eq("2222") } its([:account_number]) { is_expected.to eq("3333333044") } end + + context "when the account number is shorter than 6 chars" do + let(:account_number) { "12345" } + its([:account_number]) { is_expected.to be_nil } + end end context "without an account number" do