mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
This old gem implemented some functionality for handling nils which is no longer needed, as it's provided natively by Ruby with the &. operator.
18 lines
373 B
Ruby
18 lines
373 B
Ruby
# frozen_string_literal: true
|
|
|
|
module OpenFoodNetwork
|
|
class RefererParser
|
|
def self.path(referer)
|
|
parse_uri(referer)&.path if referer
|
|
end
|
|
|
|
def self.parse_uri(string)
|
|
# TODO: make this operation obsolete by fixing URLs generated by AngularJS
|
|
string.sub!('##', '#')
|
|
URI(string)
|
|
rescue URI::InvalidURIError
|
|
nil
|
|
end
|
|
end
|
|
end
|