about summary refs log tree commit diff
path: root/app/controllers/xrd_controller.rb
diff options
context:
space:
mode:
authorshel <Yiskah.Raphen@gmail.com>2017-03-31 10:34:14 -0400
committerGitHub <noreply@github.com>2017-03-31 10:34:14 -0400
commitf20f6b25b98efffca47caae713f8dc5e1d0d4bd1 (patch)
tree104152d4bd6f9889f38b2f46fee108185c3b29f7 /app/controllers/xrd_controller.rb
parent76188d61f2c3bb5747208df92835e912db18d7b6 (diff)
parent680f9efe9c4aa7fce1f4dd6a35ef4aca7a80c1f3 (diff)
Merge branch 'master' into patch-2
Diffstat (limited to 'app/controllers/xrd_controller.rb')
-rw-r--r--app/controllers/xrd_controller.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/app/controllers/xrd_controller.rb b/app/controllers/xrd_controller.rb
index 9e0277860..6db87cefc 100644
--- a/app/controllers/xrd_controller.rb
+++ b/app/controllers/xrd_controller.rb
@@ -36,11 +36,14 @@ class XrdController < ApplicationController
   end
 
   def username_from_resource
-    if resource_param.start_with?('acct:') || resource_param.include?('@')
-      resource_param.split('@').first.gsub('acct:', '')
+    if resource_param =~ /\Ahttps?:\/\//
+      path_params = Rails.application.routes.recognize_path(resource_param)
+      raise ActiveRecord::RecordNotFound unless path_params[:controller] == 'users' && path_params[:action] == 'show'
+      path_params[:username]
     else
-      url = Addressable::URI.parse(resource_param)
-      url.path.gsub('/users/', '')
+      username, domain = resource_param.gsub(/\Aacct:/, '').split('@')
+      raise ActiveRecord::RecordNotFound unless TagManager.instance.local_domain?(domain)
+      username
     end
   end