diff --git a/features/handles_multiple_formats.feature b/features/handles_multiple_formats.feature index 438a6ba6..2f538446 100644 --- a/features/handles_multiple_formats.feature +++ b/features/handles_multiple_formats.feature @@ -32,3 +32,11 @@ Feature: Handles Multiple Formats Then it should return a Hash equaling: | key | value | | singer | waylon jennings | + + Scenario: A Javascript remote file + Given a remote service that returns '$(function() { alert("hi"); });' + And that service is accessed at the path '/service.js' + And the response from the service has a Content-Type of 'application/javascript' + When I call HTTParty#get with '/service.js' + Then it should return a String + And the return value should match '$(function() { alert("hi"); });' diff --git a/lib/httparty/parser.rb b/lib/httparty/parser.rb index 76a103a2..b91ff460 100644 --- a/lib/httparty/parser.rb +++ b/lib/httparty/parser.rb @@ -42,8 +42,8 @@ class Parser 'application/xml' => :xml, 'application/json' => :json, 'text/json' => :json, - 'application/javascript' => :json, - 'text/javascript' => :json, + 'application/javascript' => :plain, + 'text/javascript' => :plain, 'text/html' => :html, 'text/plain' => :plain } diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index a5f505e2..dc768825 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -198,13 +198,13 @@ it 'should handle text/javascript' do ["text/javascript", "text/javascript; charset=iso8859-1"].each do |ct| - @request.send(:format_from_mimetype, ct).should == :json + @request.send(:format_from_mimetype, ct).should == :plain end end it 'should handle application/javascript' do ["application/javascript", "application/javascript; charset=iso8859-1"].each do |ct| - @request.send(:format_from_mimetype, ct).should == :json + @request.send(:format_from_mimetype, ct).should == :plain end end