lib/worldwide/zip.rb in worldwide-0.10.0 vs lib/worldwide/zip.rb in worldwide-0.10.1
- old
+ new
@@ -83,9 +83,11 @@
# @param strip_extraneous_characters [String] Allow additional stripping of characters to either fully numeric or alphanumeric depending on the country.
# @return [String] The postal code with spaces inserted/removed and other formatting fixes applied.
def normalize(country_code:, zip:, allow_autofill: true, strip_extraneous_characters: false)
input = zip # preserve the original zip, in case we need to fall back to it
+ return input if country_code.nil?
+
country = Worldwide.region(code: country_code)
return zip if country.nil? || NORMALIZATION_DISABLED_COUNTRIES.include?(country.iso_code)
if allow_autofill
autofill = country.autofill_zip