123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Journey::Router::Utils::UriEncoder

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: actionpack/lib/action_dispatch/journey/router/utils.rb

Overview

URI path and fragment escaping tools.ietf.org/html/rfc3986

Constant Summary

Instance Method Summary

Instance Method Details

#escape(component, pattern) (private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 72

def escape(component, pattern)
  component.gsub(pattern) { |unsafe| percent_encode(unsafe) }.force_encoding(US_ASCII)
end

#escape_fragment(fragment)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 59

def escape_fragment(fragment)
  escape(fragment, FRAGMENT)
end

#escape_path(path)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 63

def escape_path(path)
  escape(path, PATH)
end

#escape_segment(segment)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 67

def escape_segment(segment)
  escape(segment, SEGMENT)
end

#percent_encode(unsafe) (private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 76

def percent_encode(unsafe)
  safe = EMPTY.dup
  unsafe.each_byte { |b| safe << DEC2HEX[b] }
  safe
end