module Pagy::B64
def decode(str)
def decode(str) str.unpack1('m0') end
def encode(bin)
def encode(bin) [bin].pack('m0') end
def urlsafe_decode(str)
def urlsafe_decode(str) if !str.end_with?('=') && str.length % 4 != 0 str = str.ljust((str.length + 3) & ~3, '=') str.tr!('-_', '+/') else str = str.tr('-_', '+/') end decode(str) end
def urlsafe_encode(bin)
def urlsafe_encode(bin) str = encode(bin) str.chomp!('==') or str.chomp!('=') str.tr!('+/', '-_') str end