lib/roda/plugins/backtracking_array.rb in roda-1.1.0 vs lib/roda/plugins/backtracking_array.rb in roda-1.2.0

- old
+ new

@@ -33,14 +33,17 @@ # elements. If the remaining elements could not be # matched, reset the state and continue to the next # entry in the array. def _match_array(arg, rest=nil) return super unless rest - env = @env - script = env[SCRIPT_NAME] - path = env[PATH_INFO] + unless path = @remaining_path + e = @env + script = e[SCRIPT_NAME] + path = e[PATH_INFO] + end + captures = @captures caps = captures.dup arg.each do |v| if match(v, rest) if v.is_a?(String) captures.push(v) @@ -50,11 +53,15 @@ return true end # Matching all remaining elements failed, reset state captures.replace(caps) - env[SCRIPT_NAME] = script - env[PATH_INFO] = path + if @remaining_path + @remaining_path = path + else + e[SCRIPT_NAME] = script + e[PATH_INFO] = path + end end end false end