Sha256: e1fe8b2b02e05fccd7f19361fa2ef5f52a0307b83059f611841c264e328bece0

Contents?: true

Size: 727 Bytes

Versions: 7

Compression:

Stored size: 727 Bytes

Contents

module WWW
  class Mechanize
    class Util
      class << self
        def build_query_string(parameters)
          parameters.map { |k,v|
            k &&
              [WEBrick::HTTPUtils.escape_form(k.to_s),
                WEBrick::HTTPUtils.escape_form(v.to_s)].join("=")
          }.compact.join('&')
        end

        def html_unescape(s)
          return s unless s
          s.gsub(/&(\w+|#[0-9]+);/) { |match|
            number = case match
            when /&(\w+);/
              Mechanize.html_parser::NamedCharacters[$1]
            when /&#([0-9]+);/
              $1.to_i
            end
  
            number ? ([number].pack('U') rescue match) : match
          }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mechanize-0.8.0 lib/www/mechanize/util.rb
mechanize-0.8.1 lib/www/mechanize/util.rb
mechanize-0.8.2 lib/www/mechanize/util.rb
mechanize-0.8.3 lib/www/mechanize/util.rb
mechanize-0.8.4 lib/www/mechanize/util.rb
mechanize-0.8.5 lib/www/mechanize/util.rb
mechanize-0.9.0 lib/www/mechanize/util.rb