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

Commit e7e3aef

Browse files
committed
Workaround missing HTTP response headers for CORS requests
See angular/angular.js#1468 See https://bugzilla.mozilla.org/show_bug.cgi?id=608735
1 parent c66fda1 commit e7e3aef

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

blissful.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ function ProjectController($scope, $http, $resource, $filter) {
266266
return false;
267267
};
268268

269-
var noTransform = function(data) { return data; };
270-
271269
$scope.select = function(i) {
272270
$scope.save(function() {
273271
_select(i)
@@ -284,16 +282,24 @@ function ProjectController($scope, $http, $resource, $filter) {
284282
});
285283
}
286284

285+
var noJsonTransform = function(data) { return data; };
286+
287287
var _select = function(i) {
288288
$scope.currentIndex = i;
289289

290290
url = '//' + $scope.config.BLISS_USER_CONTENT_HOST +
291291
document.location.pathname + 'getfile/' +
292292
encodeURI($scope.currentFilename());
293-
$http.get(url, {transformResponse: noTransform})
293+
$http.get(url, {transformResponse: noJsonTransform})
294294
.success(function(data, status, headers, config) {
295295
// e.g. 'text/html; charset=UTF-8'
296296
var mime_type = headers('Content-Type');
297+
// Workaround missing HTTP response headers for CORS requests
298+
// See https://github.com/angular/angular.js/issues/1468
299+
// See https://bugzilla.mozilla.org/show_bug.cgi?id=608735
300+
if (!mime_type) {
301+
mime_type = 'application/octet-stream';
302+
}
297303
// strip '; charset=...'
298304
mime_type = mime_type.replace(/ ?;.*/, '');
299305
if (/^image\//.test(mime_type)) {

0 commit comments

Comments
 (0)