prioritize browser detection, remove os dependency #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So this is a reasonably simple change, but one that should have a pretty big impact for people who have been hit with the code path which is returning a false positive on node detection (see #54).
It changes two things:
We do browser detection if at all possible (i.e.
navigator
is defined). This then falls back to detecting the node environment if that isn't available.Removes the
require('os')
import for os detection and simply usesprocess.platform
instead. The information won't be as detailed and it's possible that a user of this module may still want to opt to do their own check using theos
module. Given that the majority use case is web browser detection though I think that makes sense. Should stopbrowserify
bringing in any shims for theos
module also (which is a good thing).Because of point 2 though, I believe we should do a major version bump to
3.0.0
to ensure that no-one that is usingdetect-browser
in an isomorphic way is caught out unexpectedly.@5punk PTAL.
/cc @shengshiqi @markgoho-EDT