class ActionDispatch::Journey::Router::Utils::UriEncoder
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/action_dispatch/journey/router/utils.rbs class ActionDispatch::Journey::Router::Utils::UriEncoder def escape: (String component, Regexp pattern) -> untyped def escape_segment: (String segment) -> untyped end
:nodoc:
URI path and fragment escaping
def escape(component, pattern)
Experimental RBS support (using type sampling data from the type_fusion
project).
def escape: (String component, Regexp pattern) -> untyped
This signature was generated using 5 samples from 1 application.
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)
Experimental RBS support (using type sampling data from the type_fusion
project).
def escape_segment: (String segment) -> untyped
This signature was generated using 4 samples from 1 application.
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