class ActionDispatch::Routing::Mapper
Inherits From
-
module
ActionDispatch::
Routing:: Mapper:: Base -
module
ActionDispatch::
Routing:: Mapper:: HttpHelpers -
module
ActionDispatch::
Routing:: Redirection -
module
ActionDispatch::
Routing:: Mapper:: Scoping -
module
ActionDispatch::
Routing:: Mapper:: Concerns -
module
ActionDispatch::
Routing:: Mapper:: Resources -
module
ActionDispatch::
Routing:: Mapper:: CustomUrls
Constants
Public class methods
Source code GitHub
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 424
def self.normalize_name(name)
normalize_path(name)[1..-1].tr("/", "_")
end
Invokes Journey::Router::Utils.normalize_path, then ensures that /(:locale) becomes (/:locale). Except for root cases, where the former is the correct one.
Source code GitHub
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 409
def self.normalize_path(path)
path = Journey::Router::Utils.normalize_path(path)
# the path for a root URL at this point can be something like
# "/(/:locale)(/:platform)/(:browser)", and we would want
# "/(:locale)(/:platform)(/:browser)" reverse "/(", "/((" etc to "(/", "((/" etc
path.gsub!(%r{/(\(+)/?}, '\1/')
# if a path is all optional segments, change the leading "(/" back to "/(" so it
# evaluates to "/" when interpreted with no options. Unless, however, at least
# one secondary segment consists of a static part, ex.
# "(/:locale)(/pages/:page)"
path.sub!(%r{^(\(+)/}, '/\1') if %r{^(\(+[^)]+\))(\(+/:[^)]+\))*$}.match?(path)
path
end