Skip to content

Commit

Permalink
Add additional check to only extract titles from questions
Browse files Browse the repository at this point in the history
  • Loading branch information
jpotts244 committed Oct 11, 2018
1 parent 50c69de commit 126fab1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/post.rb
Expand Up @@ -138,7 +138,7 @@ def get_revision_count # rubocop:disable Style/AccessorMethodName
end

def parse_domains
hosts = (URI.extract(body || '') + URI.extract(title || '')).map do |x|
hosts = part_to_extract_from_domains.map do |x|
begin
URI.parse(x).hostname.gsub(/www\./, '').downcase
rescue
Expand All @@ -153,4 +153,12 @@ def parse_domains
Rails.cache.delete "spam_domain_post_counts_##{domain.id}"
end
end

private

def part_to_extract_from_domains
answer? ?
URI.extract(body || '') :
(URI.extract(body || '') + URI.extract(title || ''))
end
end

0 comments on commit 126fab1

Please sign in to comment.