class ActionDispatch::Journey::Router::Utils::UriEncoder
:nodoc:
URI path and fragment escaping
def escape(component, pattern)
def escape(component, pattern) component.gsub(pattern) { |unsafe| percent_encode(unsafe) }.force_encoding(US_ASCII) end
def escape_fragment(fragment)
def escape_fragment(fragment) escape(fragment, FRAGMENT) end
def escape_path(path)
def escape_path(path) escape(path, PATH) end
def escape_segment(segment)
def escape_segment(segment) escape(segment, SEGMENT) end
def percent_encode(unsafe)
def percent_encode(unsafe) safe = EMPTY.dup unsafe.each_byte { |b| safe << DEC2HEX[b] } safe end
def unescape_uri(uri)
def unescape_uri(uri) encoding = uri.encoding == US_ASCII ? UTF_8 : uri.encoding uri.gsub(ESCAPED) { |match| [match[1, 2].hex].pack("C") }.force_encoding(encoding) end