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

Function defaultHttpResponseTransform

test/angular/1.6/angular.js:11439–11463  ·  view source on GitHub ↗
(data, headers)

Source from the content-addressed store, hash-verified

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