Module: LongURL::URL
- Defined in:
- lib/longurl/url.rb
Class Method Summary collapse
-
.check(url) ⇒ Object
Check given
url
Raises LongURL::InvalidURL ifurl
is invalid.
Class Method Details
.check(url) ⇒ Object
Check given url
Raises LongURL::InvalidURL if url
is invalid. Returns a parsed http uri object on success.
9 10 11 12 13 14 15 16 |
# File 'lib/longurl/url.rb', line 9 def self.check(url) raise LongURL::InvalidURL if url.nil? or url.empty? result = URI.parse(url) raise LongURL::InvalidURL unless result.is_a?(URI::HTTP) result rescue URI::InvalidURIError raise LongURL::InvalidURL end |