Skip to content

Commit

Permalink
Fixed Chrome-detection on iOS
Browse files Browse the repository at this point in the history
Previously it was returing "Safari" all the time even if you're checking
on a Chrome browser. Reason: both has same userAgent.
  • Loading branch information
muaz-khan committed Oct 26, 2018
1 parent c315a58 commit f354738
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
12 changes: 9 additions & 3 deletions DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

// Last Updated On: 2018-10-09 7:06:12 AM UTC
// Last Updated On: 2018-10-26 9:36:48 AM UTC

// ________________
// DetectRTC v1.3.6
// DetectRTC v1.3.7

// Open-Sourced: https://github.com/muaz-khan/DetectRTC

Expand Down Expand Up @@ -96,6 +96,12 @@
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset, verOffset, ix;

// both and safri and chrome has same userAgent
if (isSafari && !isChrome && nAgt.indexOf('CriOS') !== -1) {
isSafari = false;
isChrome = true;
}

// In Opera, the true version is after 'Opera' or after 'Version'
if (isOpera) {
browserName = 'Opera';
Expand Down Expand Up @@ -1093,7 +1099,7 @@
DetectRTC.isPromisesSupported = !!('Promise' in window);

// version is generated by "grunt"
DetectRTC.version = '1.3.6';
DetectRTC.version = '1.3.7';

if (typeof DetectRTC === 'undefined') {
window.DetectRTC = {};
Expand Down
6 changes: 3 additions & 3 deletions DetectRTC.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ module.exports = function(grunt) {
pushTo: 'upstream',
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d'
}
},
watch: {
scripts: {
files: ['dev/*.js'],
tasks: ['concat', 'replace', 'jsbeautifier', 'uglify', 'clean'],
options: {
spawn: false,
},
}
}
});

Expand All @@ -144,4 +153,5 @@ module.exports = function(grunt) {
// set default tasks to run when grunt is called without parameters
// http://gruntjs.com/api/grunt.task
grunt.registerTask('default', ['concat', 'replace', 'jsbeautifier', 'uglify', 'clean']);
grunt.loadNpmTasks('grunt-contrib-watch');
};
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "detectrtc",
"version": "1.3.6",
"version": "1.3.7",
"authors": [
{
"name": "Muaz Khan",
Expand Down
6 changes: 6 additions & 0 deletions dev/getBrowserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ function getBrowserInfo() {
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset, verOffset, ix;

// both and safri and chrome has same userAgent
if (isSafari && !isChrome && nAgt.indexOf('CriOS') !== -1) {
isSafari = false;
isChrome = true;
}

// In Opera, the true version is after 'Opera' or after 'Version'
if (isOpera) {
browserName = 'Opera';
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "detectrtc",
"preferGlobal": false,
"version": "1.3.6",
"version": "1.3.7",
"author": {
"name": "Muaz Khan",
"email": "[email protected]",
Expand Down Expand Up @@ -51,6 +51,7 @@
"grunt-jsbeautifier": "0.2.10",
"grunt-replace": "0.11.0",
"grunt-contrib-clean": "0.6.0",
"grunt-bump": "0.7.0"
"grunt-bump": "0.7.0",
"grunt-contrib-watch": "^1.1.0"
}
}

0 comments on commit f354738

Please sign in to comment.