Class: ActionDispatch::Journey::Router::Utils
- Defined in:
- actionpack/lib/action_dispatch/journey/router/utils.rb
Overview
:nodoc:
Defined Under Namespace
Modules: UriEscape
Class Method Summary collapse
- .escape_fragment(fragment) ⇒ Object
- .escape_path(path) ⇒ Object
-
.normalize_path(path) ⇒ Object
Normalizes URI path.
- .unescape_uri(uri) ⇒ Object
Class Method Details
.escape_fragment(fragment) ⇒ Object
44 45 46 |
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 44 def self.escape_fragment(fragment) Parser.escape(fragment.to_s, UriEscape::UNSAFE_FRAGMENT) end |
.escape_path(path) ⇒ Object
40 41 42 |
# File 'actionpack/lib/action_dispatch/journey/router/utils.rb', line 40 def self.escape_path(path) Parser.escape(path.to_s, UriEscape::UNSAFE_SEGMENT) end |
.normalize_path(path) ⇒ Object
Normalizes URI path.
Strips off trailing slash and ensures there is a leading slash.
normalize_path("/foo") # => "/foo"
normalize_path("/foo/") # => "/foo"
normalize_path("foo") # => "/foo"
normalize_path("") # => "/"
15 16 17 18 19 20 21 |
# 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 = '/' if path == '' path end |