Module URI
In: lib/simpy.rb

Methods

esc  

Public Class methods

Properly escape strings that will be included in a URL

Args

str:The string to transform

Description

Ruby’s built-in URL encoding method ignores symbols like equals and ampersand by design. Since this method properly encodes symbols that have syntactic relevance in URLs, it is not intended for use on strings that contain complete URLs.

Usage

  {"a" => "test 1", "b" => "test 2"}.map {|x,y| "#{x}=#{URI.esc y}"}.join "&"
  # => "a=test%201&b=test%202"

[Source]

    # File lib/simpy.rb, line 95
95:   def URI.esc str
96:     URI.encode(str.to_s).gsub("&", "%26").gsub("=", "%3D")
97:   end

[Validate]