enspirit/webspicy · scope.rb
ruby logo
def to_real_url(url, test_case = nil, &bl)
      case config.host
      when Proc
        config.host.call(url, test_case)
      when String
        url =~ /^http/ ? url : "#{config.host}#{url}"
      else
        return url if url =~ /^http/
        return yield(url) if block_given?
        raise "Unable to resolve `#{url}` : no host resolver provided\nSee `Configuration#host="
      end
    end
Similar code snippets
1.
QueueClassic/queue_classic · conn_adapter.rb
Match rating: 53.93% · See similar code snippets
ruby logo
def normalize_db_url(url)
      host = url.host
      host = host.gsub(/%2F/i, '/') if host

      [
       host, # host or percent-encoded socket path
       url.port || 5432,
       nil, '', #opts, tty
       url.path.gsub("/",""), # database name
       url.user,
       url.password
      ]
    end
2.
blambeau/finitio-rb · compilation.rb
Match rating: 52.64% · See similar code snippets
ruby logo
def resolve_url(url)
      if url.to_s =~ /^\.\//
        resolve_relative_url(url)
      else
        STDLIB_PATHS.each do |path|
          file = File.expand_path("#{url}.fio", path)
          return Pathname.new(file) if File.file?(file)
        end
        raise Error, "No such import `#{url}`"
      end
    end
3.
4rlm/crm_formatter · web.rb
Match rating: 50.14% · See similar code snippets
ruby logo
def normalize_url(url)
      return unless url.present?
      uri = URI(url)
      scheme = uri&.scheme
      host = uri&.host
      url = "#{scheme}://#{host}" if host.present? && scheme.present?
      url = "http://#{url}" if url[0..3] != 'http'

      return unless url.present?
      url.gsub!('//', '//www.') unless url.include?('www.')
      url
    end
4.
svenfuchs/steam · request.rb
Match rating: 49.38% · See similar code snippets
ruby logo
def url=(url)
      url = URI.parse(url)
      self.path   = url.path
      self.scheme = url.scheme if url.scheme
      self.host   = url.host   if url.host
      self.port   = url.port   if url.port
      self.query  = url.query  if url.query
    end
5.
cloudfoundry/cf-uaac · common.rb
Match rating: 48.7% · See similar code snippets
ruby logo
def normalize_url(url, scheme = nil)
    url = url.strip.gsub(/\/*$/, "")
    raise ArgumentError, "invalid whitespace in target url" if url =~ /\s/
    unless url =~ /^https?:\/\//
      return unless scheme
      url = "#{scheme}://#{url}"
    end
    url = URI.parse(url)
    url.host.downcase!
    url.to_s.to_sym
  end
6.
piotrmurach/loaf · view_extensions.rb
Match rating: 48.55% · See similar code snippets
ruby logo
def _expand_url(url)
      case url
      when String, Symbol
        respond_to?(url) ? send(url) : url
      when Proc
        url.call(self)
      else
        url
      end
    end
7.
yamasolutions/integral · list_item_renderer.rb
Match rating: 48.03% · See similar code snippets
ruby logo
def url
      return if list_item.basic?
      url = provide_attr(:url)

      return url if url.nil? || url.empty?
      return url if url.match?(URI::DEFAULT_PARSER.make_regexp)

      "#{Rails.application.routes.default_url_options[:host]}#{url}"
    end
8.
brynary/webrat · mechanize.rb
Match rating: 47.61% · See similar code snippets
ruby logo
def absolute_url(url) #:nodoc:
      current_host, current_path = split_current_url
      if url =~ Regexp.new('^https?://')
        url
      elsif url =~ Regexp.new('^/')
        current_host + url
      elsif url =~ Regexp.new('^\.')
        current_host + absolute_path(current_path, url)
      else
        url
      end
    end
9.
savonrb/httpi · request.rb
Match rating: 47.43% · See similar code snippets
ruby logo
def normalize_url!(url)
      raise ArgumentError, "Invalid URL: #{url}" unless url.to_s =~ /^http|socks/
      url.kind_of?(URI) ? url : URI(url)
    end
10.
chriskite/anemone · http.rb
Match rating: 47.12% · See similar code snippets
ruby logo
def allowed?(to_url, from_url)
      to_url.host.nil? || (to_url.host == from_url.host)
    end