Comparing version 1.3.0 to 1.3.1
var detect = require('./detect'); | ||
var match = require('./match'); | ||
var url = require('url'); | ||
function useNewFormat() { | ||
return match('firefox') || match('chrome', '>=36'); | ||
} | ||
module.exports = function(server) { | ||
@@ -14,3 +9,3 @@ var uri; | ||
// if we have a url parameter parse it | ||
if (server && server.url && useNewFormat()) { | ||
if (server && server.url) { | ||
uri = url.parse(server.url); | ||
@@ -20,6 +15,6 @@ auth = (uri.auth || '').split(':'); | ||
return { | ||
url: uri.protocol + uri.host, | ||
urls: [ uri.protocol + uri.host ], | ||
url: uri.protocol + uri.host + (uri.search || ''), | ||
urls: [ uri.protocol + uri.host + (uri.search || '') ], | ||
username: auth[0], | ||
credential: auth[1] | ||
credential: server.credential || auth[1] | ||
}; | ||
@@ -26,0 +21,0 @@ } |
{ | ||
"name": "rtc-core", | ||
"description": "Core definitions and functions for the rtc.io suite", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "semver": "^2" |
@@ -11,6 +11,52 @@ var test = require('tape'); | ||
var turnFormatA = [ | ||
{ url: 'turn:tmp:test@hoth.rtc.io:3478' }, | ||
{ url: 'turn:tmp:test@hoth.rtc.io' } | ||
{ url: 'turn:tmp:test@example.org:3478' }, | ||
{ url: 'turn:tmp@example.org:3478', credential: 'test' }, | ||
{ url: 'turn:tmp@example.org', credential: 'test' }, | ||
{ url: 'turn:tmp@example.org?transport=tcp', credential: 'test' } | ||
]; | ||
test('normalizing turn url with embedded username:credential', function(t) { | ||
var server; | ||
t.plan(5); | ||
t.ok(server = normalize(turnFormatA[0])); | ||
t.equal(server.url, 'turn:example.org:3478'); | ||
t.deepEqual(server.urls, ['turn:example.org:3478']); | ||
t.equal(server.username, 'tmp'); | ||
t.equal(server.credential, 'test'); | ||
}); | ||
test('normalizing turn url with embedded username', function(t) { | ||
var server; | ||
t.plan(5); | ||
t.ok(server = normalize(turnFormatA[1])); | ||
t.equal(server.url, 'turn:example.org:3478'); | ||
t.deepEqual(server.urls, ['turn:example.org:3478']); | ||
t.equal(server.username, 'tmp'); | ||
t.equal(server.credential, 'test'); | ||
}); | ||
test('normalizing turn url with embedded username (no port)', function(t) { | ||
var server; | ||
t.plan(5); | ||
t.ok(server = normalize(turnFormatA[2])); | ||
t.equal(server.url, 'turn:example.org'); | ||
t.deepEqual(server.urls, ['turn:example.org']); | ||
t.equal(server.username, 'tmp'); | ||
t.equal(server.credential, 'test'); | ||
}); | ||
test('normalizing turn url with embedded username (transport specified)', function(t) { | ||
var server; | ||
t.plan(5); | ||
t.ok(server = normalize(turnFormatA[3])); | ||
t.equal(server.url, 'turn:example.org?transport=tcp'); | ||
t.deepEqual(server.urls, ['turn:example.org?transport=tcp']); | ||
t.equal(server.username, 'tmp'); | ||
t.equal(server.credential, 'test'); | ||
}); | ||
test('can detect an RTCPeerConnection constructor', function(t) { | ||
@@ -17,0 +63,0 @@ t.plan(1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29253
400