From 6cad40762321a1436d9c9c5a2175e832486d4613 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 29 Apr 2012 22:51:04 +0100 Subject: Restore interpolation of path option in redirect routes --- actionpack/lib/action_dispatch/routing/redirection.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index 866a2f5602..dc28389360 100644 --- a/actionpack/lib/action_dispatch/routing/redirection.rb +++ b/actionpack/lib/action_dispatch/routing/redirection.rb @@ -1,4 +1,5 @@ require 'action_dispatch/http/request' +require 'active_support/core_ext/uri' require 'rack/utils' module ActionDispatch @@ -47,8 +48,17 @@ module ActionDispatch :params => request.query_parameters }.merge options + if !params.empty? && url_options[:path].match(/%\{\w*\}/) + url_options[:path] = (url_options[:path] % escape_path(params)) + end + ActionDispatch::Http::URL.url_for url_options end + + private + def escape_path(params) + Hash[params.map{ |k,v| [k, URI.parser.escape(v)] }] + end end module Redirection -- cgit v1.2.3