mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #6317 from nbianca/ignore_blacklisted_domains
FIX: Ignore OneBox blacklisted domains.
This commit is contained in:
@@ -47,6 +47,14 @@ describe FinalDestination do
|
||||
FinalDestination.new(url, opts)
|
||||
end
|
||||
|
||||
it 'correctly parses ignored hostnames' do
|
||||
fd = FinalDestination.new('https://meta.discourse.org',
|
||||
ignore_redirects: ['http://google.com', 'youtube.com', 'https://meta.discourse.org', '://bing.com']
|
||||
)
|
||||
|
||||
expect(fd.ignored).to eq(['test.localhost', 'google.com', 'meta.discourse.org'])
|
||||
end
|
||||
|
||||
describe '.resolve' do
|
||||
|
||||
it "has a ready status code before anything happens" do
|
||||
|
||||
@@ -107,4 +107,13 @@ describe Oneboxer do
|
||||
end
|
||||
end
|
||||
|
||||
it "does not crawl blacklisted URLs" do
|
||||
SiteSetting.onebox_domains_blacklist = "git.*.com|bitbucket.com"
|
||||
url = 'https://github.com/discourse/discourse/commit/21b562852885f883be43032e03c709241e8e6d4f'
|
||||
stub_request(:head, 'https://discourse.org/').to_return(status: 302, body: "", headers: { location: url })
|
||||
|
||||
expect(Oneboxer.external_onebox(url)[:onebox]).to be_empty
|
||||
expect(Oneboxer.external_onebox('https://discourse.org/')[:onebox]).to be_empty
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user