module ElFinder2::HashUtils
Public Instance Methods
from_base64url(hash)
click to toggle source
# File lib/el_finder2/hash_utils.rb, line 3 def from_base64url(hash) padding = ['', '', '==', '='][hash.length % 4] # ensure input is padded Base64.urlsafe_decode64(hash + padding) end
to_base64url(string)
click to toggle source
# File lib/el_finder2/hash_utils.rb, line 8 def to_base64url(string) Base64.urlsafe_encode64(string).tr("=\n", '') end
to_path(hash, default = nil)
click to toggle source
# File lib/el_finder2/hash_utils.rb, line 12 def to_path(hash, default = nil) volume_id, target = hash.split('_') valid = volume_id == ElFinder2::VOLUME_ID && target valid && from_base64url(target) || default rescue ArgumentError default end