mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Restrict matching with word boundary or end of string
This commit is contained in:
parent
c94754e2f0
commit
1315582b37
2 changed files with 12 additions and 12 deletions
|
@ -119,7 +119,7 @@ module ActionDispatch
|
|||
|
||||
class UnanchoredRegexp < AnchoredRegexp # :nodoc:
|
||||
def accept(node)
|
||||
%r{\A#{visit node}\b}
|
||||
%r{\A#{visit node}(?:\b|\Z)}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -34,17 +34,17 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
{
|
||||
"/:controller(/:action)" => %r{\A/(#{x})(?:/([^/.?]+))?\b},
|
||||
"/:controller/foo" => %r{\A/(#{x})/foo\b},
|
||||
"/:controller/:action" => %r{\A/(#{x})/([^/.?]+)\b},
|
||||
"/:controller" => %r{\A/(#{x})\b},
|
||||
"/:controller(/:action(/:id))" => %r{\A/(#{x})(?:/([^/.?]+)(?:/([^/.?]+))?)?\b},
|
||||
"/:controller/:action.xml" => %r{\A/(#{x})/([^/.?]+)\.xml\b},
|
||||
"/:controller.:format" => %r{\A/(#{x})\.([^/.?]+)\b},
|
||||
"/:controller(.:format)" => %r{\A/(#{x})(?:\.([^/.?]+))?\b},
|
||||
"/:controller/*foo" => %r{\A/(#{x})/(.+)\b},
|
||||
"/:controller/*foo/bar" => %r{\A/(#{x})/(.+)/bar\b},
|
||||
"/:foo|*bar" => %r{\A/(?:([^/.?]+)|(.+))\b},
|
||||
"/:controller(/:action)" => %r{\A/(#{x})(?:/([^/.?]+))?(?:\b|\Z)},
|
||||
"/:controller/foo" => %r{\A/(#{x})/foo(?:\b|\Z)},
|
||||
"/:controller/:action" => %r{\A/(#{x})/([^/.?]+)(?:\b|\Z)},
|
||||
"/:controller" => %r{\A/(#{x})(?:\b|\Z)},
|
||||
"/:controller(/:action(/:id))" => %r{\A/(#{x})(?:/([^/.?]+)(?:/([^/.?]+))?)?(?:\b|\Z)},
|
||||
"/:controller/:action.xml" => %r{\A/(#{x})/([^/.?]+)\.xml(?:\b|\Z)},
|
||||
"/:controller.:format" => %r{\A/(#{x})\.([^/.?]+)(?:\b|\Z)},
|
||||
"/:controller(.:format)" => %r{\A/(#{x})(?:\.([^/.?]+))?(?:\b|\Z)},
|
||||
"/:controller/*foo" => %r{\A/(#{x})/(.+)(?:\b|\Z)},
|
||||
"/:controller/*foo/bar" => %r{\A/(#{x})/(.+)/bar(?:\b|\Z)},
|
||||
"/:foo|*bar" => %r{\A/(?:([^/.?]+)|(.+))(?:\b|\Z)},
|
||||
}.each do |path, expected|
|
||||
define_method(:"test_to_non_anchored_regexp_#{Regexp.escape(path)}") do
|
||||
path = Pattern.build(
|
||||
|
|
Loading…
Reference in a new issue