Class: DynamicLinks::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamic_links/validator.rb

Class Method Summary collapse

Class Method Details

.valid_url?(url) ⇒ Boolean

Validates if the given URL is a valid HTTP or HTTPS URL

Parameters:

  • url (String)

    The URL to validate

Returns:

  • (Boolean)

    true if valid, false otherwise



6
7
8
9
10
11
# File 'lib/dynamic_links/validator.rb', line 6

def self.valid_url?(url)
  uri = URI.parse(url)
  uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
rescue URI::InvalidURIError
  false
end