diff --git a/app/models/user.rb b/app/models/user.rb index edb80a5db..beb4f1f6c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -80,6 +80,13 @@ class User < Person def mine?(post) self == post.person end + + def terse_url + terse= self.url.gsub(/https?:\/\//, '') + terse.gsub!(/www\./, '') + terse = terse.chop! if terse[-1, 1] == '/' + terse + end def do_bad_things self.password_confirmation = self.password diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index 33112533c..53d8aeba4 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -1,7 +1,7 @@ - washington.joindiaspora.com + <%= @user.terse_url %> Resource Descriptor diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 8c0f1cf7b..854cde20b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -41,4 +41,10 @@ describe User do @user.send_friend_request_to( @friend.url ).should be nil end + + it 'should be able to give me the terse url for webfinger' do + user = Factory.create(:user) + user.terse_url.should == 'example.com' + end + end