lib/pesapal/oauth.rb in pesapal-1.5.6 vs lib/pesapal/oauth.rb in pesapal-1.6.0
- old
+ new
@@ -112,11 +112,10 @@
#
# @param params [Hash] URL parameters.
#
# @return [String] valid signature base string.
def self.generate_signature_base_string(http_method, absolute_url, params)
-
# step 1: convert the http method to uppercase
http_method = http_method.upcase
# step 2: percent encode the url
url_encoded = parameter_encode(normalized_request_uri(absolute_url))
@@ -154,15 +153,15 @@
# > _The Signature Base String includes the request absolute URL, tying the
# > signature to a specific endpoint. The URL used in the Signature Base
# > String MUST include the scheme, authority, and path, and MUST exclude
# > the query and fragment as defined by [RFC3986] section 3._
#
- # > _If the absolute request URL is not available to the Service Provider (it
- # > is always available to the Consumer), it can be constructed by combining
- # > the scheme being used, the HTTP Host header, and the relative HTTP
- # > request URL. If the Host header is not available, the Service Provider
- # > SHOULD use the host name communicated to the Consumer in the
+ # > _If the absolute request URL is not available to the Service Provider
+ # > (it is always available to the Consumer), it can be constructed by
+ # > combining the scheme being used, the HTTP Host header, and the relative
+ # > HTTP request URL. If the Host header is not available, the Service
+ # > Provider SHOULD use the host name communicated to the Consumer in the
# > documentation or other means._
#
# > _The Service Provider SHOULD document the form of URL used in the
# > Signature Base String to avoid ambiguity due to URL normalization.
# > Unless specified, URL scheme and authority MUST be lowercase and include
@@ -182,11 +181,11 @@
scheme = u.scheme.downcase
host = u.host.downcase
path = u.path
port = u.port
- port = (scheme == 'http' && port != 80) || (scheme == 'https' && port != 443) ? ":#{port}" : ""
+ port = (scheme == 'http' && port != 80) || (scheme == 'https' && port != 443) ? ":#{port}" : ''
path = (path && path != '') ? path : '/'
"#{scheme}://#{host}#{port}#{path}"
end
@@ -207,11 +206,11 @@
#
# @return [String] valid encoded result as per the spec.
def self.parameter_encode(str)
# reserved character regexp, per section 5.1
reserved_characters = /[^a-zA-Z0-9\-\.\_\~]/
- # Apparently we can't force_encoding on a frozen string since that would modify it.
- # What we can do is work with a copy
+ # Apparently we can't force_encoding on a frozen string since that would
+ # modify it. What we can do is work with a copy
URI.escape(str.dup.to_s.force_encoding(Encoding::UTF_8), reserved_characters)
end
end
end