|
|
@ -36,11 +36,14 @@ class XrdController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def username_from_resource |
|
|
|
def username_from_resource |
|
|
|
if resource_param.start_with?('acct:') || resource_param.include?('@') |
|
|
|
if resource_param =~ /\Ahttps?:\/\// |
|
|
|
resource_param.split('@').first.gsub('acct:', '') |
|
|
|
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 |
|
|
|
else |
|
|
|
url = Addressable::URI.parse(resource_param) |
|
|
|
username, domain = resource_param.gsub(/\Aacct:/, '').split('@') |
|
|
|
url.path.gsub('/users/', '') |
|
|
|
raise ActiveRecord::RecordNotFound unless TagManager.instance.local_domain?(domain) |
|
|
|
|
|
|
|
username |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|