Sha256: 1075f529970ad64811e272f5fa457eba78f81368ac1981a8148522a3225fc577

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

module Typhoeus
  module Utils
    # Taken from Rack::Utils, 1.2.1 to remove Rack dependency.
    def escape(s)
      s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/) {
        '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
      }.tr(' ', '+')
    end
    module_function :escape

    # Return the bytesize of String; uses String#size under Ruby 1.8 and
    # String#bytesize under 1.9.
    if ''.respond_to?(:bytesize)
      def bytesize(string)
        string.bytesize
      end
    else
      def bytesize(string)
        string.size
      end
    end
    module_function :bytesize
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arachni-typhoeus-0.2.0.2 lib/typhoeus/utils.rb