Sha256: 6875a96195457f6d09048b6e9dac6ad91a62e9b5b5af9d55bcf0041a87ba4ea6

Contents?: true

Size: 553 Bytes

Versions: 6

Compression:

Stored size: 553 Bytes

Contents

module SpiffyStoresApp
  module Utils

    def self.sanitize_shop_domain(shop_domain)
      name = shop_domain.to_s.strip
      name += ".#{SpiffyStoresApp.configuration.spiffy_stores_domain}" if !name.include?("#{SpiffyStoresApp.configuration.spiffy_stores_domain}") && !name.include?(".")
      name.sub!(%r|https?://|, '')

      u = URI("http://#{name}")
      u.host if u.host&.match(/^[a-z0-9][a-z0-9\-]*[a-z0-9]\.#{Regexp.escape(SpiffyStoresApp.configuration.spiffy_stores_domain)}$/)
    rescue URI::InvalidURIError
      nil
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spiffy_stores_app-8.2.11 lib/spiffy_stores_app/utils.rb
spiffy_stores_app-8.2.10 lib/spiffy_stores_app/utils.rb
spiffy_stores_app-8.2.9 lib/spiffy_stores_app/utils.rb
spiffy_stores_app-8.2.8 lib/spiffy_stores_app/utils.rb
spiffy_stores_app-8.2.7 lib/spiffy_stores_app/utils.rb
spiffy_stores_app-8.2.6 lib/spiffy_stores_app/utils.rb