Class: ActionDispatch::Journey::Router::Utils
- Defined in:
- actionpack/lib/action_dispatch/journey/router/utils.rb
Overview
:nodoc:
Defined Under Namespace
Classes: UriEncoder
Constant Summary collapse
- ENCODER =
UriEncoder.new
Class Method Summary collapse
- .escape_fragment(fragment) ⇒ Object
- .escape_path(path) ⇒ Object
- .escape_segment(segment) ⇒ Object
-
.normalize_path(path) ⇒ Object
Normalizes URI path.
- .unescape_uri(uri) ⇒ Object
Class Method Details
.escape_fragment(fragment) ⇒ Object
83 84 85 |
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 83 def self.escape_fragment(fragment) ENCODER.escape_fragment(fragment.to_s) end |
.escape_path(path) ⇒ Object
75 76 77 |
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 75 def self.escape_path(path) ENCODER.escape_path(path.to_s) end |
.escape_segment(segment) ⇒ Object
79 80 81 |
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 79 def self.escape_segment(segment) ENCODER.escape_segment(segment.to_s) end |
.normalize_path(path) ⇒ Object
Normalizes URI path.
Strips off trailing slash and ensures there is a leading slash. Also converts downcase url encoded string to uppercase.
normalize_path("/foo") # => "/foo"
normalize_path("/foo/") # => "/foo"
normalize_path("foo") # => "/foo"
normalize_path("") # => "/"
normalize_path("/%ab") # => "/%AB"
15 16 17 18 19 20 21 22 |
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 15 def self.normalize_path(path) path = "/#{path}" path.squeeze!('/') path.sub!(%r{/+\Z}, '') path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase } path = '/' if path == '' path end |