Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($templateRequest): ignore JSON Content-Type header and content #9619

Closed
wants to merge 2 commits into from

Conversation

caitp
Copy link
Contributor

@caitp caitp commented Oct 14, 2014

Normally, if there is a Content-Type header with the string
"application/json", or else the content looks sort of JSON-y, $http will
attempt to deserialize the JSON into an object. $templateRequest is intended
to request markup, and as such should never attempt to parse JSON, regardless
of the headers or shape of the content.

/CC @IgorMinar should be quick to review

Closes #5756

Normally, if there is a Content-Type header with the string "application/json", or else the content
looks sort of JSON-y, $http will attempt to deserialize the JSON into an object. $templateRequest
is intended to request markup, and as such should never attempt to parse JSON, regardless of the
headers or shape of the content.

Closes angular#5756
$templateRequest('a.html').then(spy);
$httpBackend.flush();
expect(spy).toHaveBeenCalledOnce();
expect(spy.argsForCall[0][0]).toBe('{{text}}');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toHaveBeenCalledOnceWith('{{text}}')

transformResponse.splice(idx, 1);
} else if (transformResponse === httpResponseTransform) {
transformResponse = null;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to avoid breaking change

@IgorMinar
Copy link
Contributor

otherwise lgtm

@caitp caitp closed this in 1bd473e Oct 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible bug with custom interpolates?
4 participants