]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
redirect FOAF file on non-canonical nickname
authorEvan Prodromou <evan@controlyourself.ca>
Fri, 3 Apr 2009 18:00:52 +0000 (14:00 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Fri, 3 Apr 2009 18:19:07 +0000 (14:19 -0400)
actions/foaf.php

index 3a99835b4aaef16a9a86c827886635ec09e47a0c..aa78b91c3ef9bed3f32890d25097cd76dbb5e43b 100644 (file)
@@ -33,7 +33,24 @@ class FoafAction extends Action
     function prepare($args)
     {
         parent::prepare($args);
-        $this->nickname = $this->trimmed('nickname');
+
+        $nickname_arg = $this->arg('nickname');
+
+        if (empty($nickname_arg)) {
+            $this->clientError(_('No such user.'), 404);
+            return false;
+        }
+
+        $this->nickname = common_canonical_nickname($nickname_arg);
+
+        // Permanent redirect on non-canonical nickname
+
+        if ($nickname_arg != $this->nickname) {
+            common_redirect(common_local_url('foaf',
+                                             array('nickname' => $this->nickname)),
+                            301);
+            return false;
+        }
 
         $this->user = User::staticGet('nickname', $this->nickname);