Project

General

Profile

Actions

Misc #17309

open

URI.escape being deprecated, yet there is no replacement

Added by chucke (Tiago Cardoso) about 4 years ago. Updated about 4 years ago.

Status:
Open
Assignee:
-
[ruby-core:100730]

Description

I'm on ruby 2.7.2 . The moment I do

uri = "http://bücher.ch"
URI.escape uri
(irb):5: warning: URI.escape
"http://b%C3%BCcher.ch"

I get that warning. Rubocop also tells me:

"""
URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.
"""

However, none of the suggestions does the same as URI.escape.

CGI.escape uri
=> "http%3A%2F%2Fb%C3%BCcher.ch"
URI.encode_www_form_component uri
=> "http%3A%2F%2Fb%C3%BCcher.ch"
 URI.encode_www_form uri
Traceback (most recent call last):
NoMethodError (undefined method `map' for "http://bücher.ch":String)
Did you mean?  tap

So my question is: why is this being deprecated? And if there's still reason, what to exactly replace it for, so I can keep the exact same behaviour?


Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #18593: Add back URI.escapeOpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0