Class: Doorkeeper::OAuth::Authorization::URIBuilder
- Inherits:
-
Object
- Object
- Doorkeeper::OAuth::Authorization::URIBuilder
- Defined in:
- lib/doorkeeper/oauth/authorization/uri_builder.rb
Class Method Summary collapse
Class Method Details
.uri_with_fragment(url, parameters = {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/doorkeeper/oauth/authorization/uri_builder.rb', line 28 def uri_with_fragment(url, parameters = {}) uri = URI.parse(url) uri.fragment = build_query(parameters) uri.to_s end |
.uri_with_query(url, parameters = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/doorkeeper/oauth/authorization/uri_builder.rb', line 10 def uri_with_query(url, parameters = {}) uri = URI.parse(url) original_query = Rack::Utils.parse_query(uri.query) # `parse_query` yields string keys while `parameters` uses symbol # keys, so a naive merge cannot dedupe a collision (e.g. a registered # redirect_uri already carrying `state`) and would emit the param # twice. Normalize keys so the response parameters win over any # same-named query already present in the redirect_uri. Blank # response parameters are dropped before the merge: they carry no # value to respond with, and letting them clobber a same-named # registered parameter would violate RFC 6749 ยง3.1.2 (the registered # query component "MUST be retained when adding additional query # parameters"). parameters = parameters.transform_keys(&:to_s).reject { |_, value| value.blank? } uri.query = build_query(original_query.merge(parameters)) uri.to_s end |