/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
'use strict';

var logDisabled_ = false;

// Utility methods.
var utils = {
  disableLog: function(bool) {
    if (typeof bool !== 'boolean') {
      return new Error('Argument type: ' + typeof bool +
          '. Please use a boolean.');
    }
    logDisabled_ = bool;
    return (bool) ? 'adapter.js logging disabled' :
        'adapter.js logging enabled';
  },

  log: function() {
    if (typeof window === 'object') {
      if (logDisabled_) {
        return;
      }
      console.log.apply(console, arguments);
    }
  },

   /**
   * Extract browser version out of the provided user agent string.
   * @param {!string} uastring userAgent string.
   * @param {!string} expr Regular expression used as match criteria.
   * @param {!number} pos position in the version string to be returned.
   * @return {!number} browser version.
   */
  extractVersion: function(uastring, expr, pos) {
    var match = uastring.match(expr);
    return match && match.length >= pos && parseInt(match[pos], 10);
  },

  /**
   * Browser detector.
   * @return {object} result containing browser, version and minVersion
   *     properties.
   */
  detectBrowser: function() {
    // Returned result object.
    var result = {};
    result.browser = null;
    result.version = null;
    result.minVersion = null;

    if (typeof window === 'undefined' || !window.navigator) {
      result.browser = 'Not a browser.';
      return result;
    } else if (navigator.mozGetUserMedia) {
      // Firefox.
      result.browser = 'firefox';
      result.version = this.extractVersion(navigator.userAgent,
          /Firefox\/([0-9]+)\./, 1);
      result.minVersion = 31;
    } else if (navigator.webkitGetUserMedia && window.webkitRTCPeerConnection) {
      // Chrome, Chromium, WebView, Opera and other WebKit browsers.
      result.browser = 'chrome';
      result.version = this.extractVersion(navigator.userAgent,
          /Chrom(e|ium)\/([0-9]+)\./, 2);
      result.minVersion = 38;
    } else if(navigator.mediaDevices &&
        navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)) {
      // Edge.
      result.browser = 'edge';
      result.version = this.extractVersion(navigator.userAgent,
          /Edge\/(\d+).(\d+)$/, 2);
      result.minVersion = 10547;
    } else {
      result.browser = 'Not a supported browser.';
    }

    // Warn if version is less than minVersion.
    if (!result.version  && !result.minVersion && !result.browser &&
        result.version < result.minVersion) {
      utils.log('Browser: ' + result.browser + ' Version: ' + version + ' < ' +
          'minimum supported version: ' + minVersion + '\n some things ' +
          'might not work!');
    } else {
      utils.log('Browser version could not be detected, some things might ' +
          'not work.')
    }
    return result;
  }
};

// Export.
module.exports = {
  log: utils.log,
  disableLog: utils.disableLog,
  browserDetails: utils.detectBrowser(),
  extractVersion: utils.extractVersion
};

@@ -2530,22 +2530,43 @@
 wser.';%0A
+      return result;%0A
     %7D%0A
-
 %0A    // 
@@ -2618,77 +2618,8 @@
 if (
-!result.version  && !result.minVersion && !result.browser &&%0A        
 resu
@@ -2714,16 +2714,23 @@
 on: ' + 
+result.
 version 
@@ -2734,28 +2734,23 @@
 on +
- ' %3C ' +%0A
+%0A    
       
-    '
+' %3C 
 mini
@@ -2776,16 +2776,23 @@
 on: ' + 
+result.
 minVersi
@@ -2799,127 +2799,22 @@
 on +
- '%5Cn some things ' +%0A          'might not work!');%0A    %7D else %7B%0A      utils.log('Browser version could not be detected,
+%0A          '%5Cn
  som
@@ -2832,31 +2832,16 @@
 ght 
-' +%0A          '
 not work
 .')%0A
@@ -2840,18 +2840,20 @@
 work
-.
+!
 ')
+;
 %0A    %7D%0A
+%0A
     

Fix according to comments