Allow extra qualifications when matching json content-type
This commit is contained in:
parent
d893394765
commit
54864a45d3
@ -117,7 +117,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
var defaults = [
|
var defaults = [
|
||||||
{
|
{
|
||||||
test: function(xhr) {
|
test: function(xhr) {
|
||||||
return xhr.contentType() === 'application/json';
|
return /^application\/json/.test(xhr.contentType());
|
||||||
},
|
},
|
||||||
parse: function jsonParser(paramString) {
|
parse: function jsonParser(paramString) {
|
||||||
return JSON.parse(paramString);
|
return JSON.parse(paramString);
|
||||||
|
@ -145,6 +145,23 @@ describe("FakeXMLHttpRequest", function() {
|
|||||||
expect(xhr.data()).toEqual(data);
|
expect(xhr.data()).toEqual(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should parse json even if there are further qualifiers", function() {
|
||||||
|
var data = {
|
||||||
|
foo: 'bar',
|
||||||
|
baz: ['q', 'u', 'u', 'x'],
|
||||||
|
nested: {
|
||||||
|
object: {
|
||||||
|
with: 'stuff'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
|
||||||
|
xhr.send(JSON.stringify(data));
|
||||||
|
|
||||||
|
expect(xhr.data()).toEqual(data);
|
||||||
|
});
|
||||||
|
|
||||||
it("should be able to use a custom parser", function() {
|
it("should be able to use a custom parser", function() {
|
||||||
xhr.send('custom_format');
|
xhr.send('custom_format');
|
||||||
var custom = {
|
var custom = {
|
||||||
|
Loading…
Reference in New Issue
Block a user