Sha256: 5587a6b326398ea1e66ec5ed37ba7350d2828fbcebeaf289f93dfb778bec5280

Contents?: true

Size: 952 Bytes

Versions: 20

Compression:

Stored size: 952 Bytes

Contents

# frozen_string_literal: true

module ShopifyApp
  module SanitizedParams
    protected

    def sanitized_shop_name
      @sanitized_shop_name ||= sanitize_shop_param(params)
    end

    def referer_sanitized_shop_name
      return unless request.referer.present?

      @referer_sanitized_shop_name ||= begin
        referer_uri = URI(request.referer)
        query_params = Rack::Utils.parse_query(referer_uri.query)

        sanitize_shop_param(query_params.with_indifferent_access)
      end
    end

    def sanitize_shop_param(params)
      return unless params[:shop].present?

      ShopifyApp::Utils.sanitize_shop_domain(params[:shop])
    end

    def sanitized_params
      parameters = request.post? ? request.request_parameters : request.query_parameters
      parameters.clone.tap do |params_copy|
        if params[:shop].is_a?(String)
          params_copy[:shop] = sanitize_shop_param(params)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shopify_app-22.3.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-22.2.1 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-22.2.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-22.1.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-22.0.1 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-22.00.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.10.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.9.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.8.1 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.8.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.7.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.6.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.5.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.4.1 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.4.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.3.1 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.3.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.2.0 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.1.1 lib/shopify_app/controller_concerns/sanitized_params.rb
shopify_app-21.1.0 lib/shopify_app/controller_concerns/sanitized_params.rb