module Base64Bp

backport from ruby v2.5 to v2.2 that has no `padding` things @api private

Public Instance Methods

urlsafe_decode64(str) click to toggle source
# File lib/graphql/schema/base_64_bp.rb, line 19
def urlsafe_decode64(str)
  str = str.tr("-_", "+/")
  if !str.end_with?("=") && str.length % 4 != 0
    str = str.ljust((str.length + 3) & ~3, "=")
  end
  strict_decode64(str)
end
urlsafe_encode64(bin, padding:) click to toggle source
# File lib/graphql/schema/base_64_bp.rb, line 12
def urlsafe_encode64(bin, padding:)
  str = strict_encode64(bin)
  str.tr!("+/", "-_")
  str.delete!("=") unless padding
  str
end