mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 04:42:55 +08:00
Merge pull request #1195 from initforthe/post-analyser-backtrace-fix
Post analyser backtrace fix
This commit is contained in:
commit
75282576b9
|
@ -63,9 +63,14 @@ class PostAnalyzer
|
|||
|
||||
@linked_hosts = {}
|
||||
raw_links.each do |u|
|
||||
uri = URI.parse(u)
|
||||
host = uri.host
|
||||
@linked_hosts[host] ||= 1
|
||||
begin
|
||||
uri = URI.parse(u)
|
||||
host = uri.host
|
||||
@linked_hosts[host] ||= 1
|
||||
rescue URI::InvalidURIError
|
||||
# An invalid URI does not count as a raw link.
|
||||
next
|
||||
end
|
||||
end
|
||||
@linked_hosts
|
||||
end
|
||||
|
|
|
@ -80,6 +80,11 @@ describe PostAnalyzer do
|
|||
post_analyzer = PostAnalyzer.new(raw_three_links, default_topic_id)
|
||||
post_analyzer.linked_hosts.should == {"discourse.org" => 1, "www.imdb.com" => 1}
|
||||
end
|
||||
|
||||
it 'returns blank for ipv6 output' do
|
||||
post_analyzer = PostAnalyzer.new('PING www.google.com(lb-in-x93.1e100.net) 56 data bytes', default_topic_id)
|
||||
post_analyzer.linked_hosts.should be_blank
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user