Bug #4167
closedURI.encode encodes reserved character of #
Description
=begin
URI.encode's default behavior is to follow RFC 2732 [http://tools.ietf.org/html/rfc2732] which includes # in the list of characters to URI encode.
The updated RFC 3896 [http://tools.ietf.org/html/rfc3986#section-2.2] includes # in the list of reserved characters.
This bug is present in Ruby 1.8 too.
Observed behavior:
require 'uri'
enc = URI.encode("http://google.com/moo?testo=true#anchor21")
=> "http://google.com/moo?testo=true%23anchor21"
Expected behavior:
require 'uri'
enc = URI.encode("http://google.com/moo?testo=true#anchor21")
=> "http://google.com/moo?testo=true#anchor21"
=end