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

Function defaultHttpResponseTransform

lib/test/angular/1.8.0/angular.js:12075–12099  ·  view source on GitHub ↗
(data, headers)

Source from the content-addressed store, hash-verified

12073}
12074
12075function defaultHttpResponseTransform(data, headers) {
12076 if (isString(data)) {
12077 // Strip json vulnerability protection prefix and trim whitespace
12078 var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim();
12079
12080 if (tempData) {
12081 var contentType = headers('Content-Type');
12082 var hasJsonContentType = contentType && (contentType.indexOf(APPLICATION_JSON) === 0);
12083
12084 if (hasJsonContentType || isJsonLike(tempData)) {
12085 try {
12086 data = fromJson(tempData);
12087 } catch (e) {
12088 if (!hasJsonContentType) {
12089 return data;
12090 }
12091 throw $httpMinErr('baddata', 'Data must be a valid JSON object. Received: "{0}". ' +
12092 'Parse error: "{1}"', data, e);
12093 }
12094 }
12095 }
12096 }
12097
12098 return data;
12099}
12100
12101function isJsonLike(str) {
12102 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