module HTTP::Cookie::URIParser
def escape_path(path)
Escape RFC 3986 "reserved" characters minus valid characters for path
def escape_path(path) path.sub(/\A[^?#]+/) { |p| p.gsub(/[:\[\]@]+/) { |r| CGI.escape(r) } } end
def parse(uri)
def parse(uri) URI(uri) rescue URI::InvalidURIError str = String.try_convert(uri) or raise ArgumentError, "bad argument (expected URI object or URI string)" m = URIREGEX.match(str) or raise path = m[:path] str[m.begin(:path)...m.end(:path)] = escape_path(path) uri = URI.parse(str) uri.__send__(:set_path, path) uri end