2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

Fix display host for onebox

This commit is contained in:
Tijmen Brommet 2013-03-02 00:46:55 +01:00
parent 5c986be753
commit eaef66a423
8 changed files with 30 additions and 25 deletions

View file

@ -21,7 +21,7 @@ private
<div class='source'>
<div class='info'>
<a href='https://play.google.com/store/apps/details?id=com.moosoft.parrot' target="_blank">
<img class='favicon' src="/assets/favicons/google_play.png"> google.com
<img class='favicon' src="/assets/favicons/google_play.png"> play.google.com
</a>
</div>
</div>

View file

@ -21,7 +21,7 @@ private
<div class='source'>
<div class='info'>
<a href='https://itunes.apple.com/us/app/minecraft-pocket-edition-lite/id479651754' target="_blank">
<img class='favicon' src="/assets/favicons/apple.png"> apple.com
<img class='favicon' src="/assets/favicons/apple.png"> itunes.apple.com
</a>
</div>
</div>

View file

@ -22,7 +22,7 @@ private
<div class='source'>
<div class='info'>
<a href='http://en.wikipedia.org/wiki/Ruby' target="_blank">
<img class='favicon' src="/assets/favicons/wikipedia.png"> wikipedia.org
<img class='favicon' src="/assets/favicons/wikipedia.png"> en.wikipedia.org
</a>
</div>
</div>

View file

@ -72,6 +72,24 @@ describe Oneboxer do
end
describe '#nice_host' do
it 'strips www from the domain' do
DummyOnebox.new('http://www.cnn.com/thing').nice_host.should eq 'cnn.com'
end
it 'respects double TLDs' do
DummyOnebox.new('http://news.bbc.co.uk/thing').nice_host.should eq 'news.bbc.co.uk'
end
it 'returns an empty string if the URL is bogus' do
DummyOnebox.new('whatever').nice_host.should eq ''
end
it 'returns an empty string if the URL unparsable' do
DummyOnebox.new(nil).nice_host.should eq ''
end
end
context 'without caching' do
it 'calls the onebox method of our matched class' do
Oneboxer.onebox_nocache(@dummy_onebox_url).should == 'dummy!'