class ActionView::Resolver::PathParser

:nodoc:

def build_path_regex

def build_path_regex
  handlers = Template::Handlers.extensions.map { |x| Regexp.escape(x) }.join("|")
  formats = Template::Types.symbols.map { |x| Regexp.escape(x) }.join("|")
  locales = "[a-z]{2}(?:[-_][A-Z]{2})?"
  variants = "[^.]*"
  %r{
    \A
    (?:(?<prefix>.*)/)?
    (?<partial>_)?
    (?<action>.*?)
    (?:\.(?<locale>#{locales}))??
    (?:\.(?<format>#{formats}))??
    (?:\+(?<variant>#{variants}))??
    (?:\.(?<handler>#{handlers}))?
    \z
  }x
end

def parse(path)

def parse(path)
  @regex ||= build_path_regex
  match = @regex.match(path)
  path = TemplatePath.build(match[:action], match[:prefix] || "", !!match[:partial])
  details = TemplateDetails.new(
    match[:locale]&.to_sym,
    match[:handler]&.to_sym,
    match[:format]&.to_sym,
    match[:variant]&.to_sym
  )
  ParsedPath.new(path, details)
end