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

Commit 92995bb

Browse files
vojtajinaIgorMinar
authored andcommitted
fix($http): default json transformation should not crash on angular template
The way we determine whether it's json is lame anyway. We need to change that. We should probably check the content type header...
1 parent b9707d9 commit 92995bb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/service/http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function transform(data, fns, param) {
6161
* @description
6262
*/
6363
function $HttpProvider() {
64-
var JSON_START = /^\s*[\[\{]/,
64+
var JSON_START = /^\s*(\[|\{[^\{])/,
6565
JSON_END = /[\}\]]\s*$/,
6666
PROTECTION_PREFIX = /^\)\]\}',?\n/;
6767

test/service/httpSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,16 @@ describe('$http', function() {
758758
expect(callback).toHaveBeenCalledOnce();
759759
expect(callback.mostRecentCall.args[0]).toEqual([1, 'abc', {foo:'bar'}]);
760760
});
761+
762+
763+
it('should not deserialize tpl beginning with ng expression', function() {
764+
$httpBackend.expect('GET', '/url').respond('{{some}}');
765+
$http.get('/url').on('200', callback);
766+
$httpBackend.flush();
767+
768+
expect(callback).toHaveBeenCalledOnce();
769+
expect(callback.mostRecentCall.args[0]).toEqual('{{some}}');
770+
});
761771
});
762772

763773

0 commit comments

Comments
 (0)