Skip to content

Commit

Permalink
Clean up error log
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-hank committed Aug 29, 2022
1 parent 2f5c2be commit 2bd01fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/token_urls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def disable_documents_notification_errors(token_url)
end

def token_email_spam?
return true if BlockedTokenUrlDomain.where("'#{@original_email}' ~~* name").any?
return true if BlockedTokenUrlDomain.where('? ~~* name', @original_email).any?

begin
uri = URI("http://us.stopforumspam.org/api?email=#{@original_email}")
Expand Down
15 changes: 11 additions & 4 deletions app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,17 @@ def count_by_domain(urls)
counted_urls = {}

urls.each do |url|
uri = Addressable::URI.parse(url.url)

# get just domain
domain = uri.host
begin
# Valid URIs
uri = Addressable::URI.parse(url.url)
domain = uri.host
rescue Addressable::URI::InvalidURIError
# Invalid URIs
domain = url.url
.split('/')[2]
.split(' ')[0]
.gsub(/^www\./, '')
end

if counted_urls[domain].nil?
counted_urls[domain] = {
Expand Down

0 comments on commit 2bd01fd

Please sign in to comment.