diff options
author | Daniel King <northerner@users.noreply.github.com> | 2018-02-11 22:49:18 +0000 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2018-02-11 23:49:18 +0100 |
commit | 6ef3874b2eac79cc2b602de609793254b8d6c611 (patch) | |
tree | 41032cc4b49c7fb3c574e700dcedf7e32d3f1814 /spec | |
parent | e20700fe8fa22562d3df10ad0361e65676a01231 (diff) |
Fix URLs incorrectly having trailing hyphen removed (#6465)
In cases where a URL has a trailing hyphen the FetchLinkCardService incorrectly removes the hyphen when it is parsed The hyphen is not a reserved character in the URI spec https://tools.ietf.org/html/rfc3986#section-2.2
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/fetch_link_card_service_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb index ba61d22c3..edacc4425 100644 --- a/spec/services/fetch_link_card_service_spec.rb +++ b/spec/services/fetch_link_card_service_spec.rb @@ -15,6 +15,8 @@ RSpec.describe FetchLinkCardService do stub_request(:head, 'http://example.com/日本語').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) stub_request(:get, 'http://example.com/日本語').to_return(request_fixture('sjis.txt')) stub_request(:head, 'https://github.com/qbi/WannaCry').to_return(status: 404) + stub_request(:head, 'http://example.com/test-').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) + stub_request(:get, 'http://example.com/test-').to_return(request_fixture('idn.txt')) subject.call(status) end @@ -63,6 +65,14 @@ RSpec.describe FetchLinkCardService do expect(status.preview_cards.first.title).to eq("SJISのページ") end end + + context do + let(:status) { Fabricate(:status, text: 'test http://example.com/test-') } + + it 'works with a URL ending with a hyphen' do + expect(a_request(:get, 'http://example.com/test-')).to have_been_made.at_least_once + end + end end context 'in a remote status' do |