Browse files

always return a string from find_script_name

this allows us to avoid nil checks on the return value
  • Loading branch information...
1 parent cfbb5a2 commit 8cbcd19d7079db1b5df6ddb3b813fea57cd5cc38 @tenderlove tenderlove committed Aug 1, 2014
View
12 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -620,11 +620,13 @@ def define_generate_prefix(app, name)
app.routes.extend Module.new {
def optimize_routes_generation?; false; end
define_method :find_script_name do |options|
- super(options) || begin
- prefix_options = options.slice(*_route.segment_keys)
- # we must actually delete prefix segment keys to avoid passing them to next url_for
- _route.segment_keys.each { |k| options.delete(k) }
- _routes.url_helpers.send("#{name}_path", prefix_options)
+ if options.key? :script_name
+ super(options)
+ else
+ prefix_options = options.slice(*_route.segment_keys)
+ # we must actually delete prefix segment keys to avoid passing them to next url_for
+ _route.segment_keys.each { |k| options.delete(k) }
+ _routes.url_helpers.send("#{name}_path", prefix_options)
end
end
}
View
4 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -694,7 +694,7 @@ def optimize_routes_generation?
end
def find_script_name(options)
- options.delete :script_name
+ options.delete(:script_name) { '' }
end
# The +options+ argument must be a hash whose keys are *symbols*.
@@ -713,7 +713,7 @@ def url_for(options, route_name = nil, url_strategy = UNKNOWN)
original_script_name = options.delete(:original_script_name)
script_name = find_script_name options
- if script_name && original_script_name
+ if original_script_name
script_name = original_script_name + script_name
end

0 comments on commit 8cbcd19

Please sign in to comment.