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

Commit

Permalink
Workaround missing HTTP response headers for CORS requests
Browse files Browse the repository at this point in the history
  • Loading branch information
fredsa committed Oct 17, 2012
1 parent c66fda1 commit e7e3aef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions blissful.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ function ProjectController($scope, $http, $resource, $filter) {
return false;
};

var noTransform = function(data) { return data; };

$scope.select = function(i) {
$scope.save(function() {
_select(i)
Expand All @@ -284,16 +282,24 @@ function ProjectController($scope, $http, $resource, $filter) {
});
}

var noJsonTransform = function(data) { return data; };

var _select = function(i) {
$scope.currentIndex = i;

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

0 comments on commit e7e3aef

Please sign in to comment.