Skip to content

Commit c26696a

Browse files
exherbkamilogorek
authored andcommitted
fix: use safe _window and _navigator references (#1324)
- use _window.history instead of history (history is undefined in wechat miniapp environment) - use _navigator.userAgent instead of navigator (navigator is undefined in wechat miniapp environment)
1 parent c306608 commit c26696a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/raven.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,8 @@ Raven.prototype = {
14481448
var hasPushAndReplaceState =
14491449
!isChromePackagedApp &&
14501450
_window.history &&
1451-
history.pushState &&
1452-
history.replaceState;
1451+
_window.history.pushState &&
1452+
_window.history.replaceState;
14531453
if (autoBreadcrumbs.location && hasPushAndReplaceState) {
14541454
// TODO: remove onpopstate handler on uninstall()
14551455
var oldOnPopState = _window.onpopstate;
@@ -1478,8 +1478,8 @@ Raven.prototype = {
14781478
};
14791479
};
14801480

1481-
fill(history, 'pushState', historyReplacementFunction, wrappedBuiltIns);
1482-
fill(history, 'replaceState', historyReplacementFunction, wrappedBuiltIns);
1481+
fill(_window.history, 'pushState', historyReplacementFunction, wrappedBuiltIns);
1482+
fill(_window.history, 'replaceState', historyReplacementFunction, wrappedBuiltIns);
14831483
}
14841484

14851485
if (autoBreadcrumbs.console && 'console' in _window && console.log) {
@@ -1769,7 +1769,7 @@ Raven.prototype = {
17691769

17701770
if (this._hasNavigator && _navigator.userAgent) {
17711771
httpData.headers = {
1772-
'User-Agent': navigator.userAgent
1772+
'User-Agent': _navigator.userAgent
17731773
};
17741774
}
17751775

0 commit comments

Comments
 (0)