lib/rack/utils.rb in rack-3.1.7 vs lib/rack/utils.rb in rack-3.1.8
- old
+ new
@@ -22,10 +22,11 @@
InvalidParameterError = QueryParser::InvalidParameterError
ParamsTooDeepError = QueryParser::ParamsTooDeepError
DEFAULT_SEP = QueryParser::DEFAULT_SEP
COMMON_SEP = QueryParser::COMMON_SEP
KeySpaceConstrainedParams = QueryParser::Params
+ URI_PARSER = defined?(::URI::RFC2396_PARSER) ? ::URI::RFC2396_PARSER : ::URI::DEFAULT_PARSER
class << self
attr_accessor :default_query_parser
end
# The default amount of nesting to allowed by hash parameters.
@@ -41,16 +42,16 @@
end
# Like URI escaping, but with %20 instead of +. Strictly speaking this is
# true URI escaping.
def escape_path(s)
- ::URI::DEFAULT_PARSER.escape s
+ URI_PARSER.escape s
end
# Unescapes the **path** component of a URI. See Rack::Utils.unescape for
# unescaping query parameters or form components.
def unescape_path(s)
- ::URI::DEFAULT_PARSER.unescape s
+ URI_PARSER.unescape s
end
# Unescapes a URI escaped string with +encoding+. +encoding+ will be the
# target encoding of the string returned, and it defaults to UTF-8
def unescape(s, encoding = Encoding::UTF_8)