Skip to content

Commit

Permalink
Duplicate options before mutating them
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Apr 18, 2013
1 parent 6183e1a commit 3ba6ae9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions actionpack/lib/action_dispatch/http/url.rb
Expand Up @@ -28,6 +28,7 @@ def extract_subdomain(host, tld_length = @@tld_length)
end end


def url_for(options = {}) def url_for(options = {})
options = options.dup
path = options.delete(:script_name).to_s.chomp("/") path = options.delete(:script_name).to_s.chomp("/")
path << options.delete(:path).to_s path << options.delete(:path).to_s


Expand Down
7 changes: 4 additions & 3 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -170,9 +170,10 @@ def initialize(route, options)


def call(t, args) def call(t, args)
if args.size == arg_size && !args.last.is_a?(Hash) && optimize_routes_generation?(t) if args.size == arg_size && !args.last.is_a?(Hash) && optimize_routes_generation?(t)
@options.merge!(t.url_options) if t.respond_to?(:url_options) options = @options.dup
@options[:path] = optimized_helper(args) options.merge!(t.url_options) if t.respond_to?(:url_options)
ActionDispatch::Http::URL.url_for(@options) options[:path] = optimized_helper(args)
ActionDispatch::Http::URL.url_for(options)
else else
super super
end end
Expand Down

0 comments on commit 3ba6ae9

Please sign in to comment.