Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Remove NormalizeString and any_ascii dependency (#13709)
Damian Legawiec80a874611287
diff --git a/server/Gemfile.lock b/server/Gemfile.lockindex 7289b7898f..0fdb82c5f4 100644--- a/server/Gemfile.lock+++ b/server/Gemfile.lock@@ -52,7 +52,6 @@ PATHactive_storage_validations (= 1.3.0)acts-as-taggable-onacts_as_list (>= 0.8)- any_ascii (~> 0.3.2)ar_lazy_preload (~> 2.0)awesome_nested_set (~> 3.3, >= 3.3.1)bcrypt (~> 3.1)@@ -181,7 +180,6 @@ GEMaddressable (2.8.8)public_suffix (>= 2.0.2, < 8.0)alba (3.10.0)- any_ascii (0.3.3)ar_lazy_preload (2.1.1)ast (2.4.3)async (2.36.0)@@ -901,7 +899,6 @@ CHECKSUMSacts_as_list (1.2.6) sha256=8345380900b7bee620c07ad00991ccee59af3d8c9e8574f426e321da2865fdc8addressable (2.8.8) sha256=7c13b8f9536cf6364c03b9d417c19986019e28f7c00ac8132da4eb0fe393b057alba (3.10.0) sha256=52769d2328da35c4f1bbcfe96b3931b9c8595667307a902573868b1cf6d65d79- any_ascii (0.3.3) sha256=9bba37e4aadc7c57bc29e4bae520418416d1b69ea167d04f2aeaf9c07166f724ar_lazy_preload (2.1.1) sha256=47b8240fd1bdceb9a6b66f756cfdda6292bc213edf5a8be5f37299077ae7a734ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383async (2.36.0) sha256=090623f4c65706664355c9efa6c7bfb86771a513e65cd681c51cb27747530550diff --git a/spree/core/app/models/spree/address.rb b/spree/core/app/models/spree/address.rbindex f121d8aa4f..bc2d32bc22 100644--- a/spree/core/app/models/spree/address.rb+++ b/spree/core/app/models/spree/address.rb@@ -27,8 +27,6 @@ module Spree# those attributes depending of the logic of their applicationsADDRESS_FIELDS = %w(firstname lastname company address1 address2 city state zipcode country phone)EXCLUDED_KEYS_FOR_COMPARISON = %w(id updated_at created_at deleted_at label user_id public_metadata private_metadata)- FIELDS_TO_NORMALIZE = %w(firstname lastname phone alternative_phone company address1 address2 city zipcode)-if defined?(Spree::Security::Addresses)include Spree::Security::Addressesend@@ -53,7 +51,6 @@ module Spreebefore_validation :normalize_countrybefore_validation :normalize_statebefore_validation :clear_invalid_state_entities, if: -> { country.present? }, on: :update- before_validation :remove_emoji_and_normalizeafter_create :set_user_attributes, if: -> { user.present? }@@ -294,17 +291,6 @@ module Spreeendend- def remove_emoji_and_normalize- attributes_to_normalize = attributes.slice(*FIELDS_TO_NORMALIZE)- normalized_attributes = attributes_to_normalize.compact_blank.deep_transform_values do |value|- NormalizeString.remove_emoji_and_normalize(value.to_s).strip- end-- normalized_attributes.transform_keys! { |key| key.gsub('original_', '') } if defined?(Spree::Security::Addresses)-- assign_attributes(normalized_attributes)- end-def set_user_attributesif user.name.blank?user.first_name = firstnamediff --git a/spree/core/lib/normalize_string.rb b/spree/core/lib/normalize_string.rbdeleted file mode 100644index 23bf6ae26d..0000000000--- a/spree/core/lib/normalize_string.rb+++ /dev/null@@ -1,18 +0,0 @@-require 'any_ascii'--module NormalizeString- def self.normalize(string)- return unless string.present?-- AnyAscii.transliterate(string)- end-- def self.remove_emoji_and_normalize(string, keep_emoji_when_empty: false)- return unless string.present?-- result = AnyAscii.transliterate(string.gsub(/\p{So}/, ''))- return result if result.present? || !keep_emoji_when_empty-- normalize(string)- end-enddiff --git a/spree/core/lib/spree_core.rb b/spree/core/lib/spree_core.rbindex d57d8d32d5..2b00f9ba98 100644--- a/spree/core/lib/spree_core.rb+++ b/spree/core/lib/spree_core.rb@@ -1,6 +1,5 @@require 'friendly_id/paranoia'require 'friendly_id/history_decorator'require 'mobility/plugins/store_based_fallbacks'-require 'normalize_string'require 'spree/core'diff --git a/spree/core/spec/models/spree/address_spec.rb b/spree/core/spec/models/spree/address_spec.rbindex 5a8bf5bec6..5f3cd98f9b 100644--- a/spree/core/spec/models/spree/address_spec.rb+++ b/spree/core/spec/models/spree/address_spec.rb@@ -3,33 +3,6 @@ require 'spec_helper'describe Spree::Address, type: :model doit_behaves_like 'metadata'- describe 'before_validation :remove_emoji_and_normalize' do- let(:address) do- create(:address,- firstname: 'Jan 👋',- lastname: 'Масник',- phone: '1234567😃89',- alternative_phone: '😊 234567890',- company: 'общество',- address1: 'Default Street 123🌴',- address2: '🎂Apartment 6',- city: 'Варшава',- zipcode: '35005 👋 '- )- end-- it 'normalizes the address and removes emojis' do- expect(address.firstname).to eq('Jan')- expect(address.lastname).to eq('Masnik')- expect(address.phone).to eq('123456789')- expect(address.alternative_phone).to eq('234567890')- expect(address.company).to eq('obshchestvo')- expect(address.address1).to eq('Default Street 123')- expect(address.address2).to eq('Apartment 6')- expect(address.city).to eq('Varshava')- end- end-describe 'after_commit :async_geocode' dolet(:address) { build(:address) }diff --git a/spree/core/spree_core.gemspec b/spree/core/spree_core.gemspecindex bb072d4388..8b5a1a6d55 100644--- a/spree/core/spree_core.gemspec+++ b/spree/core/spree_core.gemspec@@ -62,7 +62,6 @@ Gem::Specification.new do |s|s.add_dependency 'mobility-actiontext', '~> 1.1's.add_dependency 'friendly_id-mobility', '~> 1.0's.add_dependency 'wannabe_bool'- s.add_dependency 'any_ascii', '~> 0.3.2's.add_dependency 'safely_block', '~> 0.4's.add_dependency 'phonelib', '~> 0.10's.add_dependency 'ar_lazy_preload', '~> 2.0'