Skip to content

Commit

Permalink
Merge pull request #16 from brianpursley/master
Browse files Browse the repository at this point in the history
Fixed some errors that can occur when using Edge browser, when RTCPeerConnection is not implemented (ie. Edge), and when candidates have IPv6 addresses (Chrome and others too?)
  • Loading branch information
muaz-khan committed Nov 30, 2015
2 parents 079f0dc + 344c674 commit bee1a47
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
16 changes: 13 additions & 3 deletions DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated at Monday, November 16th, 2015, 9:04:34 PM
// Last time updated at Sunday, November 29th, 2015, 8:05:29 PM

// Latest file can be found here: https://cdn.webrtc-experiment.com/DetectRTC.js

Expand Down Expand Up @@ -101,7 +101,7 @@
if (isEdge) {
browserName = 'Edge';
// fullVersion = navigator.userAgent.split('Edge/')[1];
fullVersion = parseInt(navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)[2], 10);
fullVersion = parseInt(navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)[2], 10).toString();
}

// trim the fullVersion string at semicolon/space if present
Expand Down Expand Up @@ -243,6 +243,11 @@
useWebKit = !!win.webkitRTCPeerConnection;
}

// if still no RTCPeerConnection then it is not supported by the browser so just return
if (!RTCPeerConnection) {
return;
}

//minimal requirements for data connection
var mediaConstraints = {
optional: [{
Expand Down Expand Up @@ -276,7 +281,12 @@
function handleCandidate(candidate) {
//match just the IP address
var ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3})/;
var ipAddress = ipRegex.exec(candidate)[1];
var match = ipRegex.exec(candidate);
if (!match) {
console.warn('Could not match IP address in', candidate);
return;
}
var ipAddress = match[1];

//remove duplicates
if (ipDuplicates[ipAddress] === undefined) {
Expand Down
Loading

0 comments on commit bee1a47

Please sign in to comment.