lib/vidibus/validate_uri/core.rb
# Returns true if given URI is valid.
#
# To restrict URI to a certain protocol, provide :protocol option:
#
#   valid_uri?(your_uri, :protocol => :rtmp)
#   valid_uri?(your_uri, :protocol => [:rtsp, :rtmp])
#
Returns true if given URI is valid.
To restrict URI to a certain protocol, provide :protocol option.


Returns true if given URI is valid . To restrict URI to a certain protocol provide : protocol option .
def valid_uri?(uri, options = {})
        return false if uri.blank?
        if protocol = options[:protocol]
          protocol = [protocol] unless p.is_a?(Array)
          protocol_regexp = /#{protocol.join('|')}/
        else
          protocol_regexp = /\w+/
        end
        regexp = /^#{protocol_regexp}:\/\/(localhost|#{DOMAIN_REGEXP}|#{IP_REGEXP})#{PORT_REGEXP}#{PATH_REGEXP}#{PARAMS_REGEXP}#{FRAGMENT_REGEXP}$/i
        return !!uri.match(regexp)
      end
def valid_uri? ( uri , options = { } ) return false if uri . blank? if protocol = options [ :protocol ] protocol = [ protocol ] unless p . is_a? ( Array ) protocol_regexp = / #{ protocol . join ( '|' ) } / else protocol_regexp = / \w + / end regexp = / ^ #{ protocol_regexp } : \/ \/ (localhost| #{ DOMAIN_REGEXP } | #{ IP_REGEXP } ) #{ PORT_REGEXP } #{ PATH_REGEXP } #{ PARAMS_REGEXP } #{ FRAGMENT_REGEXP } $ /i return ! ! uri . match ( regexp ) end
Returns true if given URI is valid.
Returns true if given URI is valid .
uri
<not_specific>
options
<not_specific>