mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #39494 from jonathanhefner/pathparser-lazy-regex
Lazily build path regex in PathParser
This commit is contained in:
commit
d8d32f2535
2 changed files with 4 additions and 5 deletions
|
@ -36,10 +36,6 @@ module ActionView
|
|||
end
|
||||
|
||||
class PathParser # :nodoc:
|
||||
def initialize
|
||||
@regex = build_path_regex
|
||||
end
|
||||
|
||||
def build_path_regex
|
||||
handlers = Template::Handlers.extensions.map { |x| Regexp.escape(x) }.join("|")
|
||||
formats = Template::Types.symbols.map { |x| Regexp.escape(x) }.join("|")
|
||||
|
@ -60,6 +56,7 @@ module ActionView
|
|||
end
|
||||
|
||||
def parse(path)
|
||||
@regex ||= build_path_regex
|
||||
match = @regex.match(path)
|
||||
{
|
||||
prefix: match[:prefix] || "",
|
||||
|
|
|
@ -77,7 +77,9 @@ module ApplicationTests
|
|||
source
|
||||
end
|
||||
end
|
||||
ActiveSupport.on_load :action_view do
|
||||
ActionView::Template.register_template_handler(:rubby, RubbyHandler)
|
||||
end
|
||||
RUBY
|
||||
|
||||
get "/"
|
||||
|
|
Loading…
Reference in a new issue