I need help understanding what is correct way to replace deprecated URI.escape
> URI.escape('space ^%$')
(pry):12: warning: URI.escape is obsolete
=> "space%20%5E%25$
Current implementation is this:
def escape(*arg)
warn "URI.escape is obsolete", uplevel: 1
DEFAULT_PARSER.escape(*arg)
end
so, just using DEFAULT_PARSER
seems to work:
> URI::DEFAULT_PARSER.escape('space ^%$')
=> "space%20%5E%25$"
but also explicitly stating the parser seems to work as well:
> URI::RFC2396_Parser.new.escape('space ^%$')
=> "space%20%5E%25$"
What I'm looking for is the context on the Ruby change, so an informed decision could be made.
- why was it deprecated
- why was it moved to RFC2396_Parser? Should we expect new URI parsers?
- are there plans to switch URI::DEFAULT_PARSER?