Allow extra qualifications when matching json content-type

master v2.0.0
slackersoft 10 years ago
parent d893394765
commit 54864a45d3

@ -117,7 +117,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var defaults = [
{
test: function(xhr) {
return xhr.contentType() === 'application/json';
return /^application\/json/.test(xhr.contentType());
},
parse: function jsonParser(paramString) {
return JSON.parse(paramString);

@ -145,6 +145,23 @@ describe("FakeXMLHttpRequest", function() {
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() {
xhr.send('custom_format');
var custom = {

Loading…
Cancel
Save