@@ -196,6 +196,36 @@ def test_api_endpoint_ignores_trans_domain_values
196196 dns . verify
197197 end
198198
199+ def test_api_endpoint_ignores_trans_domain_values_that_starts_with_original
200+ uri = URI . parse "http://example.com/foo"
201+ target = MiniTest ::Mock . new
202+ target . expect :target , "example.combadguy.com"
203+
204+ dns = MiniTest ::Mock . new
205+ dns . expect :getresource , target , [ String , Object ]
206+
207+ fetch = Gem ::RemoteFetcher . new nil , dns
208+ assert_equal URI . parse ( "http://example.com/foo" ) , fetch . api_endpoint ( uri )
209+
210+ target . verify
211+ dns . verify
212+ end
213+
214+ def test_api_endpoint_ignores_trans_domain_values_that_end_with_original
215+ uri = URI . parse "http://example.com/foo"
216+ target = MiniTest ::Mock . new
217+ target . expect :target , "badexample.com"
218+
219+ dns = MiniTest ::Mock . new
220+ dns . expect :getresource , target , [ String , Object ]
221+
222+ fetch = Gem ::RemoteFetcher . new nil , dns
223+ assert_equal URI . parse ( "http://example.com/foo" ) , fetch . api_endpoint ( uri )
224+
225+ target . verify
226+ dns . verify
227+ end
228+
199229 def test_cache_update_path
200230 uri = URI 'http://example/file'
201231 path = File . join @tempdir , 'file'
0 commit comments