parent::prepare($args);
$this->uri = $this->trimmed('uri');
- $acct = Discovery::normalize($this->uri);
-
- list($nick, $domain) = explode('@', substr(urldecode($acct), 5));
- $nick = common_canonical_nickname($nick);
-
- $this->user = User::staticGet('nickname', $nick);
+ $this->uri = Discovery::normalize($this->uri);
+
+ if (Discovery::isWebfinger($this->uri)) {
+ list($nick, $domain) = explode('@', substr(urldecode($this->uri), 5));
+ $nick = common_canonical_nickname($nick);
+ $this->user = User::staticGet('nickname', $nick);
+ } else {
+ $this->user = User::staticGet('uri', $this->uri);
+ }
if (!$this->user) {
$this->clientError(_('No such user.'), 404);
return false;
{
public function discover($uri)
{
- if (!Discovery::isWebfinger($uri)) {
- return false;
+ if (Discovery::isWebfinger($uri)) {
+ // We have a webfinger acct: - start with host-meta
+ list($name, $domain) = explode('@', $uri);
+ } else {
+ $domain = parse_url($uri, PHP_URL_HOST);
}
-
- // We have a webfinger acct: - start with host-meta
- list($name, $domain) = explode('@', $uri);
+
$url = 'http://'. $domain .'/.well-known/host-meta';
$xrd = Discovery::fetchXrd($url);