Skip to content

Commit

Permalink
Fix potential crash during server-side rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
feimosi committed May 7, 2017
1 parent c048439 commit 6a58481
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DetectRTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
var browserFakeUserAgent = 'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45';

var isNodejs = typeof process === 'object' && typeof process.versions === 'object' && process.versions.node;

// Do nothing during server-side rendering
if (process && process.browser && typeof window === 'undefined') {
return;
}

if (isNodejs) {
var version = process.versions.node.toString().replace('v', '');
browserFakeUserAgent = 'Nodejs/' + version + ' (NodeOS) AppleWebKit/' + version + ' (KHTML, like Gecko) Nodejs/' + version + ' Nodejs/' + version
Expand Down

0 comments on commit 6a58481

Please sign in to comment.