Skip to content

Commit 8d2a68b

Browse files
committed
should handle empty string crossOrigin
Expected behavior when empty string is given should be that of the 'anonymous' string. Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes
1 parent ed0a23a commit 8d2a68b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/raven.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ function makeRequest(data) {
760760
var img = newImage(),
761761
src = globalServer + authQueryString + '&sentry_data=' + encodeURIComponent(JSON.stringify(data));
762762

763-
if (globalOptions.crossOrigin) {
763+
if (globalOptions.crossOrigin || globalOptions.crossOrigin === '') {
764764
img.crossOrigin = globalOptions.crossOrigin;
765765
}
766766

test/raven.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,15 @@ describe('globals', function() {
11061106
assert.equal(imageCache[0].crossOrigin, 'something');
11071107
});
11081108

1109+
it('should populate crossOrigin if empty string', function() {
1110+
globalOptions = {
1111+
crossOrigin: ''
1112+
};
1113+
makeRequest({foo: 'bar'});
1114+
assert.equal(imageCache.length, 1);
1115+
assert.equal(imageCache[0].crossOrigin, '');
1116+
});
1117+
11091118
it('should not populate crossOrigin if falsey', function() {
11101119
globalOptions = {
11111120
crossOrigin: false

0 commit comments

Comments
 (0)