mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix: Content type with "+json" suffix are now parsed as JSON
This commit is contained in:
@@ -298,7 +298,27 @@ export function test_xhr_responseType_switched_to_JSON_if_header_present() {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
xhr._loadResponse(response);
|
||||
|
||||
TKUnit.assertEqual(xhr.responseType, "json");
|
||||
TKUnit.assertEqual(xhr.response.data, 42);
|
||||
}
|
||||
|
||||
export function test_xhr_responseType_switched_to_JSON_if_headers_content_type_has_json_suffix() {
|
||||
const xhr = <any>new XMLHttpRequest();
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
content: {
|
||||
toString: function () {
|
||||
return this.raw
|
||||
},
|
||||
raw: '{"data": 42}'
|
||||
},
|
||||
headers: {
|
||||
"Content-Type": "type/media.type+json"
|
||||
}
|
||||
};
|
||||
xhr._loadResponse(response);
|
||||
|
||||
TKUnit.assertEqual(xhr.responseType, "json");
|
||||
|
||||
Reference in New Issue
Block a user