From d6f84c91038f53e71e367054a2708ad46a193cee Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:56:08 +0100 Subject: [PATCH] Drop `base64` gem dependency --- lib/protocol/http/header/authorization.rb | 6 ++---- protocol-http.gemspec | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/protocol/http/header/authorization.rb b/lib/protocol/http/header/authorization.rb index 1ea9018..a4d9eea 100644 --- a/lib/protocol/http/header/authorization.rb +++ b/lib/protocol/http/header/authorization.rb @@ -3,8 +3,6 @@ # Released under the MIT License. # Copyright, 2019-2023, by Samuel Williams. -require 'base64' - module Protocol module HTTP module Header @@ -21,10 +19,10 @@ def credentials 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 diff --git a/protocol-http.gemspec b/protocol-http.gemspec index 5986656..97e61a8 100644 --- a/protocol-http.gemspec +++ b/protocol-http.gemspec @@ -22,6 +22,4 @@ Gem::Specification.new do |spec| spec.files = Dir.glob(['{lib}/**/*', '*.md'], File::FNM_DOTMATCH, base: __dir__) spec.required_ruby_version = ">= 3.0" - - spec.add_dependency "base64" end