lib/protocol/http/header/authorization.rb in protocol-http-0.26.0 vs lib/protocol/http/header/authorization.rb in protocol-http-0.26.1
- old
+ new
@@ -1,12 +1,10 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.
-require 'base64'
-
module Protocol
module HTTP
module Header
# Used for basic authorization.
#
@@ -19,13 +17,13 @@
def credentials
self.split(/\s+/, 2)
end
def self.basic(username, password)
- encoded = "#{username}:#{password}"
+ strict_base64_encoded = ["#{username}:#{password}"].pack('m0')
self.new(
- "Basic #{Base64.strict_encode64(encoded)}"
+ "Basic #{strict_base64_encoded}"
)
end
end
end
end