lib/cuba.rb in cuba-3.8.1 vs lib/cuba.rb in cuba-3.9.0

- old
+ new

@@ -3,10 +3,11 @@ class Cuba SLASH = "/".freeze EMPTY = "".freeze SEGMENT = "([^\\/]+)".freeze DEFAULT = "text/html; charset=utf-8".freeze + REGEXES = Hash.new { |h, pattern| h[pattern] = /\A\/(#{pattern})(\/|\z)/ } class Response LOCATION = "Location".freeze attr_accessor :status @@ -209,10 +210,10 @@ env[Rack::SCRIPT_NAME], env[Rack::PATH_INFO] = script, path end private :try def consume(pattern) - matchdata = env[Rack::PATH_INFO].match(/\A\/(#{pattern})(\/|\z)/) + matchdata = env[Rack::PATH_INFO].match(REGEXES[pattern]) return false unless matchdata path, *vars = matchdata.captures