FIX: Correct user profile URLs in `/about` crawler view

FIX: Correct user profile URLs in /about crawler view

diff --git a/app/views/about/index.html.erb b/app/views/about/index.html.erb
index 34d034c..22a81ee 100644
--- a/app/views/about/index.html.erb
+++ b/app/views/about/index.html.erb
@@ -14,8 +14,8 @@
   <div class='admins-list' itemscope itemtype='http://schema.org/ItemList'>
     <% @about.admins.each do |user| %>
       <div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
-        <meta itemprop='url' content='<%= user_path(user) %>'>
-        <a href='<%= user_path(user) %>' itemprop='item'>
+        <meta itemprop='url' content='<%= user_path(user.username_lower) %>'>
+        <a href='<%= user_path(user.username_lower) %>' itemprop='item'>
           <span itemprop='image'>
             <img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
           </span>
@@ -35,8 +35,8 @@
     <div class='moderators-list' itemscope itemtype='http://schema.org/ItemList'>
       <% @about.moderators.each do |user| %>
         <div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
-          <meta itemprop='url' content='<%= user_path(user) %>'>
-          <a href='<%= user_path(user) %>' itemprop='item'>
+          <meta itemprop='url' content='<%= user_path(user.username_lower) %>'>
+          <a href='<%= user_path(user.username_lower) %>' itemprop='item'>
             <span itemprop='image'>
               <img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
             </span>
diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb
index a10b766..842e9f2 100644
--- a/spec/requests/about_controller_spec.rb
+++ b/spec/requests/about_controller_spec.rb
@@ -35,6 +35,13 @@ describe AboutController do
         expect(response.status).to eq(200)
         expect(response.body).to include("<title>About - Discourse</title>")
       end
+
+      it "should include correct user URLs" do
+        Fabricate(:admin, username: "anAdminUser")
+        get '/about', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
+        expect(response.status).to eq(200)
+        expect(response.body).to include("/u/anadminuser")
+      end
     end
 
     it "serializes stats when 'Guardian#can_see_about_stats?' is true" do

GitHub sha: cc6d722d

1 Like