mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
- Added Site settings > Authentication section - Create/edit/delete your custom oauth2 configurations - Login or signup with oauth2
26 lines
623 B
Ruby
26 lines
623 B
Ruby
module OAuthsHelper
|
|
def query_path_from_hash(hash, path)
|
|
return nil unless hash.class == Hash and path.class == String
|
|
|
|
path_array = path
|
|
.split(Regexp.union([ '.', '[', ']' ])) # split by . and []
|
|
.filter { |v| not v.blank? } # remove possible blank values
|
|
.map do |v| # convert indexes to integer
|
|
if v == "0"
|
|
0
|
|
elsif v.to_i == 0
|
|
v
|
|
else
|
|
v.to_i
|
|
end
|
|
end
|
|
|
|
path_array.each do |selector|
|
|
break if hash == nil
|
|
|
|
hash = hash[selector]
|
|
end
|
|
|
|
hash
|
|
end
|
|
end |