Skip to content

Commit

Permalink
Merge pull request #514 from jpotts244/remove-extraction-of-domain-fr…
Browse files Browse the repository at this point in the history
…om-titles

Add additional check to only extract titles from questions
  • Loading branch information
ArtOfCode- committed Oct 12, 2018
2 parents 50c69de + 3e9391d commit 45aac2a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 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,14 @@ def parse_domains
Rails.cache.delete "spam_domain_post_counts_##{domain.id}"
end
end

private

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

0 comments on commit 45aac2a

Please sign in to comment.