提交 ed723486 编写于 作者: J Jean Boussier

Deduplicate strings held by the router

上级 9864f5e3
......@@ -116,7 +116,7 @@ def normalize_keys(env)
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 @@ def initialize(set, ast, defaults, controller, default_action, modyoule, to, for
@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 @@ def build_path(ast, requirements, anchor)
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 @@ def test_colon_containing_custom_param
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册