mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 17:51:36 +01:00
Strip protocol from attribution domains (#31900)
This commit is contained in:
parent
ba81e4e019
commit
c1b2c4fd9a
2 changed files with 33 additions and 1 deletions
|
@ -13,7 +13,11 @@ module Account::AttributionDomains
|
||||||
|
|
||||||
def attribution_domains_as_text=(str)
|
def attribution_domains_as_text=(str)
|
||||||
self[:attribution_domains] = str.split.filter_map do |line|
|
self[:attribution_domains] = str.split.filter_map do |line|
|
||||||
line.strip.delete_prefix('*.')
|
line
|
||||||
|
.strip
|
||||||
|
.delete_prefix('http://')
|
||||||
|
.delete_prefix('https://')
|
||||||
|
.delete_prefix('*.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -792,6 +792,34 @@ RSpec.describe Account do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#attribution_domains_as_text=' do
|
||||||
|
subject { Fabricate(:account) }
|
||||||
|
|
||||||
|
it 'sets attribution_domains accordingly' do
|
||||||
|
subject.attribution_domains_as_text = "hoge.com\nexample.com"
|
||||||
|
|
||||||
|
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'strips leading "*."' do
|
||||||
|
subject.attribution_domains_as_text = "hoge.com\n*.example.com"
|
||||||
|
|
||||||
|
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'strips the protocol if present' do
|
||||||
|
subject.attribution_domains_as_text = "http://hoge.com\nhttps://example.com"
|
||||||
|
|
||||||
|
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'strips a combination of leading "*." and protocol' do
|
||||||
|
subject.attribution_domains_as_text = "http://*.hoge.com\nhttps://*.example.com"
|
||||||
|
|
||||||
|
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'Normalizations' do
|
describe 'Normalizations' do
|
||||||
describe 'username' do
|
describe 'username' do
|
||||||
it { is_expected.to normalize(:username).from(" \u3000bob \t \u00a0 \n ").to('bob') }
|
it { is_expected.to normalize(:username).from(" \u3000bob \t \u00a0 \n ").to('bob') }
|
||||||
|
|
Loading…
Reference in a new issue