Commit 8c02e33c authored by o's avatar o
Browse files

allow searching on both ends of @

parent 570a5959
Pipeline #9130 passed with stage
in 2 minutes and 36 seconds
......@@ -29,10 +29,10 @@ class EmailIaddress < ActiveRecord::Base
by_email_assoc(local_part, domain, scope).first
end
def self.by_prefix(search_string)
def self.search(search_string)
local_part, domain = search_string.split('@', 2)
if domain
where('email_iaddresses.local_part' => local_part)
where('email_iaddresses.local_part like ?', "#{local_part}")
.joins(:email_domain)
.where('email_domains.domain like ?', "#{domain}%")
else
......
......@@ -15,7 +15,7 @@ class IApi < Sinatra::Base
end
get '/whois' do
res = EmailIaddress.by_prefix(params['search']).all.map do |e|
res = EmailIaddress.search(params['search']).all.map do |e|
{
email: e.email,
deleted: e.deleted_at || false,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment