1
0
Fork 0
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:
Kasper Timm Hansen 2020-06-01 14:29:53 +02:00 committed by GitHub
commit d8d32f2535
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View file

@ -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] || "",

View file

@ -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 "/"