-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Make sure that document is available before reading location #1038
Conversation
vendor/TraceKit/tracekit.js
Outdated
@@ -31,13 +31,11 @@ var UNKNOWN_FUNCTION = '?'; | |||
var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/; | |||
|
|||
function getLocationHref() { | |||
if (typeof document === 'undefined' || typeof document.location === 'undefined') | |||
return ''; | |||
if (document == null || document.location == null) return ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems problematic. What if document
isn't defined? Won't accessing it to make a null comparison throw an exception?
Why not do:
if (typeof document === 'undefined' || document.location == null) return '';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that. I completely forgot that document
is just a reference to window.document
and it has to obey the same rules as every other property.
f46b899
to
7670785
Compare
Updated |
Approved, but in the future, we should try to separate autoformatting changes from behavior changes. It's worth having separate PRs. |
7670785
to
ee9ffa2
Compare
I totally missed that @benvinegar, thanks for pointing that out. Fixed, merged code change only and updated PR here #1048 |
Fixes #1037
https://github.com/getsentry/raven-js/pull/1038/files?w=1#diff-05367d6a2553cabeca57c6ca111093fcR34 – this is the only real change, the rest is just prettify catching up with the rest of the files through precommit hook