Skip to content

Commit e78d54f

Browse files
committed
guard against document.location being null or undefined
fixes #356
1 parent f87e0fc commit e78d54f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/raven.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,15 @@ function now() {
680680

681681
function getHttpData() {
682682
var http = {
683-
url: document.location.href,
684683
headers: {
685684
'User-Agent': navigator.userAgent
686685
}
687686
};
688687

688+
if (document.location && document.location.href) {
689+
http.url = document.location.href;
690+
}
691+
689692
if (document.referrer) {
690693
http.headers.Referer = document.referrer;
691694
}

test/raven.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('globals', function() {
170170
var data = getHttpData();
171171

172172
it('should have a url', function() {
173-
assert.equal(data.url, window.location.href);
173+
assert.equal(data.url, window.location.href);
174174
});
175175

176176
it('should have the user-agent header', function() {
@@ -185,7 +185,6 @@ describe('globals', function() {
185185
assert.isUndefined(data.headers.Referer);
186186
}
187187
});
188-
189188
});
190189

191190
describe('isUndefined', function() {

0 commit comments

Comments
 (0)