MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / defaultHttpResponseTransform

Function defaultHttpResponseTransform

lib/test/angular/1.7.0/angular.js:11441–11465  ·  view source on GitHub ↗
(data, headers)

Source from the content-addressed store, hash-verified

11439}
11440
11441function defaultHttpResponseTransform(data, headers) {
11442 if (isString(data)) {
11443 // Strip json vulnerability protection prefix and trim whitespace
11444 var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim();
11445
11446 if (tempData) {
11447 var contentType = headers('Content-Type');
11448 var hasJsonContentType = contentType && (contentType.indexOf(APPLICATION_JSON) === 0);
11449
11450 if (hasJsonContentType || isJsonLike(tempData)) {
11451 try {
11452 data = fromJson(tempData);
11453 } catch (e) {
11454 if (!hasJsonContentType) {
11455 return data;
11456 }
11457 throw $httpMinErr('baddata', 'Data must be a valid JSON object. Received: "{0}". ' +
11458 'Parse error: "{1}"', data, e);
11459 }
11460 }
11461 }
11462 }
11463
11464 return data;
11465}
11466
11467function isJsonLike(str) {
11468 var jsonStart = str.match(JSON_START);

Callers

nothing calls this directly

Calls 3

isStringFunction · 0.70
isJsonLikeFunction · 0.70
fromJsonFunction · 0.70

Tested by

no test coverage detected