Sha256: 13951cbe52e4c34d049374a1f697986c07e82141f02088d8d234c6ae79edc0a4

Contents?: true

Size: 795 Bytes

Versions: 12

Compression:

Stored size: 795 Bytes

Contents

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 { |_, v| v.blank? }
            Rack::Utils.build_query parameters
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
doorkeeper-4.4.3 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-5.0.0 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.4.2 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.4.1 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-5.0.0.rc2 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.4.0 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-5.0.0.rc1 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.3.2 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.3.1 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.3.0 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.2.6 lib/doorkeeper/oauth/authorization/uri_builder.rb
doorkeeper-4.2.5 lib/doorkeeper/oauth/authorization/uri_builder.rb