Merge pull request #42911 from composerinteralia/remove-alter-regexp-for-custom-routes

Remove regex alteration for custom routes
This commit is contained in:
Rafael França 2021-07-29 15:48:53 -04:00 committed by GitHub
commit 1bf3ce896c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 43 deletions

View File

@ -86,10 +86,6 @@ module ActionDispatch
@name = -left.tr("*:", "")
end
def default_regexp?
regexp == DEFAULT_EXP
end
def type; :SYMBOL; end
def symbol?; true; end
end

View File

@ -136,8 +136,6 @@ module ActionDispatch
# Add a constraint for wildcard route to make it non-greedy and match the
# optional format part of the route by default.
wildcard_options[node.name.to_sym] ||= /.+?/
elsif node.cat?
alter_regex_for_custom_routes(node)
end
end
@ -211,24 +209,6 @@ module ActionDispatch
private :request_method
private
# Find all the symbol nodes that are adjacent to literal nodes and alter
# the regexp so that Journey will partition them into custom routes.
def alter_regex_for_custom_routes(node)
if node.left.literal? && node.right.symbol?
symbol = node.right
elsif node.left.literal? && node.right.cat? && node.right.left.symbol?
symbol = node.right.left
elsif node.left.symbol? && node.right.literal?
symbol = node.left
elsif node.left.symbol? && node.right.cat? && node.right.left.literal?
symbol = node.left
end
if symbol
symbol.regexp = /(?:#{Regexp.union(symbol.regexp, '-')})+/
end
end
def intern(object)
object.is_a?(String) ? -object : object
end

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
require "abstract_unit"
module ActionDispatch
module Journey
module Nodes
class TestSymbol < ActiveSupport::TestCase
def test_default_regexp?
sym = Symbol.new "foo"
assert_predicate sym, :default_regexp?
sym.regexp = nil
assert_not_predicate sym, :default_regexp?
end
end
end
end
end