lib/distack/urlsign/signer.rb in distack-urlsign-0.3.0 vs lib/distack/urlsign/signer.rb in distack-urlsign-0.3.1

- old
+ new

@@ -15,10 +15,11 @@ def sign(url) if url.opaque raise "can't sign opaque URL" end - chunks = [url.scheme, "#{url.host}:#{url.port}", url.path, url.query, url.userinfo].compact + host_with_port = url.port == url.default_port ? url.host : "#{url.host}:#{url.port}" + chunks = [url.scheme, host_with_port, url.path, url.query, url.userinfo].compact digest = OpenSSL::Digest.new("sha512") rawsig = OpenSSL::HMAC.digest(digest, @key, chunks.join) signature = Base64.urlsafe_encode64(rawsig)