Sha256: 310f152898e765c0d2ec476e6e2125f55bad80a7593e72cdced84ca59e688c50

Contents?: true

Size: 819 Bytes

Versions: 3

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

require "rack/utils"

module Doorkeeper
  module OAuth
    module Authorization
      class URIBuilder
        class << self
          def uri_with_query(url, parameters = {})
            uri = URI.parse(url)
            original_query = Rack::Utils.parse_query(uri.query)
            uri.query = build_query(original_query.merge(parameters))
            uri.to_s
          end

          def uri_with_fragment(url, parameters = {})
            uri = URI.parse(url)
            uri.fragment = build_query(parameters)
            uri.to_s
          end

          private

          def build_query(parameters = {})
            parameters = parameters.reject { |_, value| value.blank? }
            Rack::Utils.build_query(parameters)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-5.4.0 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-5.4.0.rc2 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-5.4.0.rc1 lib/doorkeeper/oauth/authorization/uri_builder.rb