mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
18 lines
394 B
Ruby
18 lines
394 B
Ruby
module OpenFoodNetwork
|
|
class RefererParser
|
|
def self.path(referer)
|
|
parse_uri(referer).andand.path if referer
|
|
end
|
|
|
|
def self.parse_uri(string)
|
|
begin
|
|
# TODO: make this operation obsolete by fixing URLs generated by AngularJS
|
|
string.sub!('##', '#')
|
|
URI(string)
|
|
rescue URI::InvalidURIError
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
end
|