module TraceView::Util::Base64URL

This module is used solely for RUM ID calculation

Public Instance Methods

decode(bin) click to toggle source
# File lib/traceview/loading.rb, line 21
def decode(bin)
  m = bin.size % 4
  bin += '=' * (4 - m) if m != 0
  bin.tr('-_', '+/').unpack('m0').first
end
encode(bin) click to toggle source
# File lib/traceview/loading.rb, line 14
def encode(bin)
  c = [bin].pack('m0').gsub(/\=+\Z/, '').tr('+/', '-_').rstrip
  m = c.size % 4
  c += '=' * (4 - m) if m != 0
  c
end