mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
Update bundler, Rails and improve tests for previous commit.
This commit is contained in:
@@ -39,7 +39,7 @@ module Devise
|
||||
# Attempt to find the mapped route for devise based on request path
|
||||
def devise_mapping
|
||||
@devise_mapping ||= begin
|
||||
mapping = Devise::Mapping.find_by_path(request.path_info)
|
||||
mapping = Devise::Mapping.find_by_path(request)
|
||||
mapping ||= Devise.mappings[Devise.default_scope] if Devise.use_default_scope
|
||||
mapping
|
||||
end
|
||||
|
||||
@@ -27,11 +27,15 @@ module Devise
|
||||
|
||||
# Loop through all mappings looking for a map that matches with the requested
|
||||
# path (ie /users/sign_in). If a path prefix is given, it's taken into account.
|
||||
def self.find_by_path(path)
|
||||
def self.find_by_path(request)
|
||||
Devise.mappings.each_value do |mapping|
|
||||
route = path.split("/")[mapping.segment_position]
|
||||
route = route.sub(/\.\w+$/, '') unless route.nil?
|
||||
return mapping if route && mapping.path == route.to_sym
|
||||
route, extra = request.path_info.split("/")[mapping.segment_position, 2]
|
||||
next unless route
|
||||
|
||||
if !extra && (format = request.params[:format])
|
||||
route.sub!(/\.#{format}$/, '')
|
||||
end
|
||||
return mapping if mapping.path == route.to_sym
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user