Sha256: 40796ae6ff47ae4ddbb2840689dd832b634a0fd67bc695dd3ebb42311ae2a97d

Contents?: true

Size: 526 Bytes

Versions: 9

Compression:

Stored size: 526 Bytes

Contents

module Katello
  module KatelloUrlHelper
    unless defined? CONSTANTS_DEFINED
      FILEPREFIX = 'file'
      PROTOCOLS = ['http', 'https', 'ftp', FILEPREFIX]

      CONSTANTS_DEFINED = true
    end

    def kurl_valid?(url)
      valid_for_prefixes(url, PROTOCOLS)
    end

    def file_prefix?(url)
      valid_for_prefixes(url, [FILEPREFIX])
    end

    private

    def valid_for_prefixes(url, prefixes)
      prefixes.include?(URI.parse(url).scheme)
    rescue URI::InvalidURIError
      return false
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-2.4.5 app/helpers/katello/katello_url_helper.rb
katello-2.4.4 app/helpers/katello/katello_url_helper.rb
katello-2.4.3 app/helpers/katello/katello_url_helper.rb
katello-2.4.2 app/helpers/katello/katello_url_helper.rb
katello-2.4.1 app/helpers/katello/katello_url_helper.rb
katello-2.4.0 app/helpers/katello/katello_url_helper.rb
katello-2.4.0.rc3 app/helpers/katello/katello_url_helper.rb
katello-2.4.0.rc2 app/helpers/katello/katello_url_helper.rb
katello-2.4.0.rc1 app/helpers/katello/katello_url_helper.rb