diff --git a/lib/rest_framework/utils.rb b/lib/rest_framework/utils.rb index 1a947b0..707a357 100644 --- a/lib/rest_framework/utils.rb +++ b/lib/rest_framework/utils.rb @@ -79,7 +79,7 @@ def self.get_routes(application_routes, request, current_route: nil) current_route ||= self.get_request_route(application_routes, request) current_path = current_route.path.spec.to_s.gsub("(.:format)", "") current_levels = current_path.count("/") - current_comparable_path = self.comparable_path(current_path) + current_comparable_path = %r{^#{Regexp.quote(self.comparable_path(current_path))}(/|$)} # Add helpful properties of the current route. path_args = current_route.required_parts.map { |n| request.path_parameters[n] } @@ -96,7 +96,7 @@ def self.get_routes(application_routes, request, current_route: nil) # to show. ( (r.defaults[:subdomain].blank? || r.defaults[:subdomain] == request.subdomain) && - self.comparable_path(r.path.spec.to_s).start_with?(current_comparable_path) && + current_comparable_path.match?(self.comparable_path(r.path.spec.to_s)) && r.defaults[:controller].present? && r.defaults[:action].present? )