mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
e0eff2c3dd
When the route definition has parameters, we can supply a regex for validation purposes: get "/a/:b" => "test#index", constraints: { b: /abc/ }, as: test This regex is going to be used to check the supplied values during link generation: test_path("abc") # check "abc" against /abc/ regex The link generation code checks each parameter. To properly validate the parameter, it creates a new regex with start and end of string modifiers: /\A#{original_regex}\Z/ This means for each link generation the code stringifies the existing regex and creates a new one. When a new regex is created, it needs to be compiled, for large regexes this can take quite a bit of time. This change memoizes the generated regex for each route when constrains are given. It also removes the RegexCaseComparator class since it is not in use anymore. |
||
---|---|---|
.. | ||
gtg | ||
nfa | ||
nodes | ||
path | ||
route/definition | ||
router | ||
route_test.rb | ||
router_test.rb | ||
routes_test.rb |