Sha256: 4d3ae59d2dcf8e4f900c45576641fee395a77787a869fb64965a87750927bef7

Contents?: true

Size: 521 Bytes

Versions: 7

Compression:

Stored size: 521 Bytes

Contents

module ShopifyApp
  module Utils

    def self.sanitize_shop_domain(shop_domain)
      name = shop_domain.to_s.strip
      name += ".#{ShopifyApp.configuration.myshopify_domain}" if !name.include?("#{ShopifyApp.configuration.myshopify_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(ShopifyApp.configuration.myshopify_domain)}$/)
    rescue URI::InvalidURIError
      nil
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shopify_app-8.3.2 lib/shopify_app/utils.rb
shopify_app-8.3.1 lib/shopify_app/utils.rb
shopify_app-8.3.0 lib/shopify_app/utils.rb
shopify_app-8.2.6 lib/shopify_app/utils.rb
shopify_app-8.2.5 lib/shopify_app/utils.rb
shopify_app-8.2.4 lib/shopify_app/utils.rb
shopify_app-8.2.2 lib/shopify_app/utils.rb