correct case where %20 decoded as space in auto link

correct case where onebox is not applied when url is decoded
This commit is contained in:
Sam
2017-07-03 16:32:53 -04:00
parent 340a3ee5cb
commit d2ba543ed3
3 changed files with 20 additions and 6 deletions

View File

@ -656,7 +656,6 @@ HTML
end
it 'handles onebox correctly' do
# we expect 2 oneboxes
expect(PrettyText.cook("http://a.com\nhttp://b.com").split("onebox").length).to eq(3)
expect(PrettyText.cook("http://a.com\n\nhttp://b.com").split("onebox").length).to eq(3)
expect(PrettyText.cook("a\nhttp://a.com")).to include('onebox')
@ -664,7 +663,6 @@ HTML
expect(PrettyText.cook("a\nhttp://a.com a")).not_to include('onebox')
expect(PrettyText.cook("a\nhttp://a.com\na")).to include('onebox')
expect(PrettyText.cook("http://a.com")).to include('onebox')
expect(PrettyText.cook("a.com")).not_to include('onebox')
expect(PrettyText.cook("http://a.com ")).to include('onebox')
expect(PrettyText.cook("http://a.com a")).not_to include('onebox')
expect(PrettyText.cook("- http://a.com")).not_to include('onebox')
@ -796,6 +794,18 @@ HTML
expect(cooked).to eq(html)
end
it "support special handling for space in urls" do
cooked = PrettyText.cook "http://testing.com?a%20b"
html = '<p><a href="http://testing.com?a%20b" class="onebox" rel="nofollow noopener">http://testing.com?a%20b</a></p>'
expect(cooked).to eq(html)
end
it "supports onebox for decoded urls" do
cooked = PrettyText.cook "http://testing.com?a%50b"
html = '<p><a href="http://testing.com?a%50b" class="onebox" rel="nofollow noopener">http://testing.com?aPb</a></p>'
expect(cooked).to eq(html)
end
end
end