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

Function defaultHttpResponseTransform

lib/test/angular/1.6.7/angular.js:11368–11392  ·  view source on GitHub ↗
(data, headers)

Source from the content-addressed store, hash-verified

11366}
11367
11368function defaultHttpResponseTransform(data, headers) {
11369 if (isString(data)) {
11370 // Strip json vulnerability protection prefix and trim whitespace
11371 var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim();
11372
11373 if (tempData) {
11374 var contentType = headers('Content-Type');
11375 var hasJsonContentType = contentType && (contentType.indexOf(APPLICATION_JSON) === 0);
11376
11377 if (hasJsonContentType || isJsonLike(tempData)) {
11378 try {
11379 data = fromJson(tempData);
11380 } catch (e) {
11381 if (!hasJsonContentType) {
11382 return data;
11383 }
11384 throw $httpMinErr('baddata', 'Data must be a valid JSON object. Received: "{0}". ' +
11385 'Parse error: "{1}"', data, e);
11386 }
11387 }
11388 }
11389 }
11390
11391 return data;
11392}
11393
11394function isJsonLike(str) {
11395 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