Class: PostHotlinkedMedia

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/post_hotlinked_media.rb

Class Method Summary collapse

Class Method Details

.normalize_src(src, reset_scheme: true) ⇒ Object



13
14
15
16
17
18
19
20
# File 'app/models/post_hotlinked_media.rb', line 13

def self.normalize_src(src, reset_scheme: true)
  uri = Addressable::URI.heuristic_parse(src)
  uri.normalize!
  uri.scheme = nil if reset_scheme
  uri.to_s
rescue URI::Error, Addressable::URI::InvalidURIError
  src
end