Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for `application/javascript` #147

Merged
merged 1 commit into from

3 participants

Davey Shafik Helgi Þormar Þorbjörnsson David Coallier
Davey Shafik
Owner
  • Make application/javascript the default for .js
  • Responds with application/javascript or text/javascript based on Accept header

Build Status

Davey Shafik dshafik Add support for `application/javascript`
- Make `application/javascript` the default for .js
- Responds with application/javascript or text/javascript based on `Accept` header
1cbfaf6
Helgi Þormar Þorbjörnsson
Owner

Would a similar fix work for #146

David Coallier davidcoallier merged commit 0f18e5f into from
Davey Shafik dshafik referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 15, 2012
  1. Davey Shafik

    Add support for `application/javascript`

    dshafik authored
    - Make `application/javascript` the default for .js
    - Responds with application/javascript or text/javascript based on `Accept` header
This page is out of date. Refresh to see the latest.
6 src/frapi/custom/Config/mimetypes.xml
View
@@ -49,5 +49,11 @@
<description></description>
<hash>033c878cd3cb4182ac91eb31f2332ddd63bcc463</hash>
</mimetype>
+ <mimetype>
+ <mimetype>application/javascript</mimetype>
+ <output_format>js</output_format>
+ <description></description>
+ <hash>a506b559c823b77ae1c78bb114ff3bb356270f86</hash>
+ </mimetype>
</mimetypes>
</frapi-config>
17 src/frapi/library/Frapi/Controller/Main.php
View
@@ -159,14 +159,15 @@ class Frapi_Controller_Main
* @var array An array of mimetypes and their output types.
*/
protected $mimeMaps = array(
- 'application/xml' => 'xml',
- 'text/xml' => 'xml',
- 'application/json' => 'json',
- 'text/json' => 'json',
- 'text/html' => 'html',
- 'text/plain' => 'json',
- 'text/javascript' => 'js',
- 'text/php-printr' => 'printr'
+ 'application/xml' => 'xml',
+ 'text/xml' => 'xml',
+ 'application/json' => 'json',
+ 'text/json' => 'json',
+ 'text/html' => 'html',
+ 'text/plain' => 'json',
+ 'application/javascript' => 'js',
+ 'text/javascript' => 'js',
+ 'text/php-printr' => 'printr'
);
/*
2  src/frapi/library/Frapi/Output.php
View
@@ -224,7 +224,7 @@ public static function getMimeTypeByFormat($format)
'xml' => 'application/xml',
'json' => 'application/json',
'html' => 'text/html',
- 'js' => 'text/javascript',
+ 'js' => 'application/javascript',
'printr' => 'text/php-printr',
);
2  src/frapi/library/Frapi/Output/JS.php
View
@@ -40,7 +40,7 @@ class Frapi_Output_JS extends Frapi_Output implements Frapi_Output_Interface
*
* @var string
*/
- public $mimeType = 'text/javascript';
+ public $mimeType = 'application/javascript';
/**
* Populate the Output
4 src/frapi/tests/unit-tests/library/Frapi/Controller/ApiTest.php
View
@@ -11,6 +11,7 @@ public function setUp()
'text/json' => 'json',
'text/html' => 'html',
'text/plain' => 'json',
+ 'application/javascript' => 'js',
'text/javascript' => 'js',
'text/php-printr' => 'printr',
'application/vnd.test.:format' => ':format',
@@ -67,6 +68,7 @@ public function acceptProvider()
array('text/html', 'html', 'text/html', array()),
array('text/plain', 'json', 'text/plain', array()),
array('text/javascript', 'js', 'text/javascript', array()),
+ array('application/javascript', 'js', 'application/javascript', array()),
array('text/php-printr', 'printr', 'text/php-printr', array()),
/* Test q-values */
@@ -122,7 +124,7 @@ public function uriProvider()
array('/foo.json', 'json', 'application/json'),
array('/foo.xml', 'xml', 'application/xml'),
array('/foo.html', 'html', 'text/html'),
- array('/foo.js', 'js', 'text/javascript'),
+ array('/foo.js', 'js', 'application/javascript'),
array('/foo.printr', 'printr', 'text/php-printr'),
/* Test Multi-segment paths */
Something went wrong with that request. Please try again.