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
|
format.html do
|
||||||
#only do it if it is an email address
|
#only do it if it is an email address
|
||||||
if params[:q].try(:match, Devise.email_regexp)
|
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?
|
webfinger(params[:q]) if people.empty?
|
||||||
else
|
else
|
||||||
people = Person.search(params[:q], current_user)
|
people = Person.search(params[:q], current_user)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ require File.join(Rails.root, 'lib/webfinger_profile')
|
||||||
class Webfinger
|
class Webfinger
|
||||||
class WebfingerFailedError < RuntimeError; end
|
class WebfingerFailedError < RuntimeError; end
|
||||||
def initialize(account)
|
def initialize(account)
|
||||||
@account = account.strip.gsub('acct:','').to_s
|
@account = account.strip.gsub('acct:','').to_s.downcase
|
||||||
@ssl = true
|
@ssl = true
|
||||||
Rails.logger.info("event=webfinger status=initialized target=#{account}")
|
Rails.logger.info("event=webfinger status=initialized target=#{account}")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,14 @@ describe PeopleController do
|
||||||
get :index, :q => "eugene@example.org"
|
get :index, :q => "eugene@example.org"
|
||||||
assigns[:people][0].id.should == eugene2.id
|
assigns[:people][0].id.should == eugene2.id
|
||||||
end
|
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
|
it "does not redirect to person page if there is exactly one match" do
|
||||||
get :index, :q => "Korth"
|
get :index, :q => "Korth"
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,12 @@ describe Webfinger do
|
||||||
n = Webfinger.new("mbs348@gmail.com")
|
n = Webfinger.new("mbs348@gmail.com")
|
||||||
n.instance_variable_get(:@account).should_not be nil
|
n.instance_variable_get(:@account).should_not be nil
|
||||||
end
|
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
|
it 'should set ssl as the default' do
|
||||||
foo = Webfinger.new(account)
|
foo = Webfinger.new(account)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue