Skip to content

Commit

Permalink
Merge pull request #1046 from Earlopain/remove-base64-dep
Browse files Browse the repository at this point in the history
Remove runtime dependency on `base64`
  • Loading branch information
bblimke committed Feb 4, 2024
2 parents 890d41e + 835cc62 commit 3c1799b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/webmock/util/headers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'base64'

module WebMock

module Util
Expand Down Expand Up @@ -59,7 +57,8 @@ def self.decode_userinfo_from_header(header)
end

def self.basic_auth_header(*credentials)
"Basic #{Base64.strict_encode64(credentials.join(':')).chomp}"
strict_base64_encoded = [credentials.join(':')].pack("m0")
"Basic #{strict_base64_encoded.chomp}"
end

def self.normalize_name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def http_request(method, url, options = {}, &block)
end
end
headers.push(
['authorization', 'Basic ' + Base64.strict_encode64(options[:basic_auth].join(':'))]
['authorization', WebMock::Util::Headers.basic_auth_header(options[:basic_auth])]
) if options[:basic_auth]

body = options[:body]
Expand Down

0 comments on commit 3c1799b

Please sign in to comment.