Class: RemoveBg::UrlValidator
- Inherits:
-
Object
- Object
- RemoveBg::UrlValidator
- Defined in:
- lib/remove_bg/url_validator.rb
Constant Summary collapse
- PERMITTED_SCHEMES =
%w[http https].freeze
Class Method Summary collapse
Class Method Details
.validate(url) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/remove_bg/url_validator.rb', line 10 def self.validate(url) parsed = URI.parse(url) raise RemoveBg::InvalidUrlError.new(url) unless parsed.absolute? && PERMITTED_SCHEMES.include?(parsed.scheme) rescue URI::InvalidURIError raise RemoveBg::InvalidUrlError.new(url) end |