ensure handle is downcased on search, fix #1912
This commit is contained in:
parent
92dcffb253
commit
bc4872d3a5
4 changed files with 16 additions and 2 deletions
|
|
@ -33,7 +33,7 @@ class PeopleController < ApplicationController
|
|||
format.html do
|
||||
#only do it if it is an email address
|
||||
if params[:q].try(:match, Devise.email_regexp)
|
||||
people = Person.where(:diaspora_handle => params[:q])
|
||||
people = Person.where(:diaspora_handle => params[:q].downcase)
|
||||
webfinger(params[:q]) if people.empty?
|
||||
else
|
||||
people = Person.search(params[:q], current_user)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ require File.join(Rails.root, 'lib/webfinger_profile')
|
|||
class Webfinger
|
||||
class WebfingerFailedError < RuntimeError; end
|
||||
def initialize(account)
|
||||
@account = account.strip.gsub('acct:','').to_s
|
||||
@account = account.strip.gsub('acct:','').to_s.downcase
|
||||
@ssl = true
|
||||
Rails.logger.info("event=webfinger status=initialized target=#{account}")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -58,6 +58,14 @@ describe PeopleController do
|
|||
assigns[:people][0].id.should == eugene2.id
|
||||
end
|
||||
|
||||
it "downcases the handle before trying to find someone by it" do
|
||||
eugene2 = Factory.create(:person, :diaspora_handle => "eugene@example.org",
|
||||
:profile => Factory.build(:profile, :first_name => "Eugene",
|
||||
:last_name => "w", :searchable => false))
|
||||
get :index, :q => "Eugene@Example.ORG"
|
||||
assigns[:people][0].id.should == eugene2.id
|
||||
end
|
||||
|
||||
it "does not redirect to person page if there is exactly one match" do
|
||||
get :index, :q => "Korth"
|
||||
response.should_not redirect_to @korth
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ describe Webfinger do
|
|||
n.instance_variable_get(:@account).should_not be nil
|
||||
end
|
||||
|
||||
it 'downcases account' do
|
||||
account = "BIGBOY@Example.Org"
|
||||
n = Webfinger.new(account)
|
||||
n.instance_variable_get(:@account).should == account.downcase
|
||||
end
|
||||
|
||||
it 'should set ssl as the default' do
|
||||
foo = Webfinger.new(account)
|
||||
foo.instance_variable_get(:@ssl).should be true
|
||||
|
|
|
|||
Loading…
Reference in a new issue