mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #35842 from Shopify/deduplicate-routing-strings
Deduplicate strings held by the router
This commit is contained in:
commit
9d02b1bd58
3 changed files with 10 additions and 6 deletions
|
@ -116,7 +116,7 @@ module ActionController
|
|||
|
||||
RACK_VALUE_TRANSLATION = {
|
||||
https: ->(v) { v ? "on" : "off" },
|
||||
method: ->(v) { v.upcase },
|
||||
method: ->(v) { -v.upcase },
|
||||
}
|
||||
|
||||
def rack_key_for(key)
|
||||
|
|
|
@ -115,9 +115,9 @@ module ActionDispatch
|
|||
@defaults = defaults
|
||||
@set = set
|
||||
|
||||
@to = to
|
||||
@default_controller = controller
|
||||
@default_action = default_action
|
||||
@to = intern(to)
|
||||
@default_controller = intern(controller)
|
||||
@default_action = intern(default_action)
|
||||
@ast = ast
|
||||
@anchor = anchor
|
||||
@via = via
|
||||
|
@ -222,6 +222,10 @@ module ActionDispatch
|
|||
private :build_path
|
||||
|
||||
private
|
||||
def intern(object)
|
||||
object.is_a?(String) ? -object : object
|
||||
end
|
||||
|
||||
def add_wildcard_options(options, formatted, path_ast)
|
||||
# Add a constraint for wildcard route to make it non-greedy and match the
|
||||
# optional format part of the route by default.
|
||||
|
|
|
@ -3379,13 +3379,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
|||
assert_match(/:param option can't contain colon/, ex.message)
|
||||
end
|
||||
|
||||
def test_action_from_path_is_not_frozen
|
||||
def test_action_from_path_is_frozen
|
||||
draw do
|
||||
get "search" => "search"
|
||||
end
|
||||
|
||||
get "/search"
|
||||
assert_not_predicate @request.params[:action], :frozen?
|
||||
assert_predicate @request.params[:action], :frozen?
|
||||
end
|
||||
|
||||
def test_multiple_positional_args_with_the_same_name
|
||||
|
|
Loading…
Reference in a new issue