Module: Katello::KatelloUrlHelper

Included in:
Validators::KatelloUrlFormatValidator
Defined in:
app/helpers/katello/katello_url_helper.rb

Constant Summary collapse

FILEPREFIX =
['file']
PROTOCOLS =
['http', 'https', 'ftp']
CONSTANTS_DEFINED =
true

Instance Method Summary collapse

Instance Method Details

#kurl_valid?(url) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'app/helpers/katello/katello_url_helper.rb', line 10

def kurl_valid?(url)
  return false if (scheme = URI.parse(url).scheme).blank?
  return true if FILEPREFIX.include?(scheme.downcase)
  URI.parse(url).host.present? && PROTOCOLS.include?(scheme.downcase)
rescue URI::InvalidURIError
  return false
end