[Pkg-javascript-commits] [sockjs-client] 293/350: Use the `auth` property of the parsed URL

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:04:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit 44d0fb4efdb37f4aaf4a2dcda20d3de27e317288
Author: Luigi Pinca <luigipinca at gmail.com>
Date:   Tue May 5 09:43:31 2015 +0200

    Use the `auth` property of the parsed URL
---
 lib/main.js       | 9 ++-------
 tests/lib/main.js | 8 +++++++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/main.js b/lib/main.js
index bc011d4..a6177b1 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -94,14 +94,9 @@ function SockJS(url, protocols, options) {
   // remove the trailing slash
   parsedUrl.path = parsedUrl.pathname.replace(/[/]+$/, '') + (parsedUrl.query || '');
 
-  // basic authentication
-  parsedUrl.auth = parsedUrl.username
-    ? parsedUrl.username + ':' + parsedUrl.password + '@'
-    : '';
-
   // store the sanitized url
-  this.url = parsedUrl.protocol + '//' + parsedUrl.auth + parsedUrl.hostname +
-    (parsedUrl.port ? ':' + parsedUrl.port : '') + parsedUrl.path;
+  this.url = parsedUrl.protocol + '//' + (parsedUrl.auth ? parsedUrl.auth + '@' : '') +
+    parsedUrl.hostname + (parsedUrl.port ? ':' + parsedUrl.port : '') + parsedUrl.path;
   debug('using url', this.url);
 
   // Step 7 - start connection in background
diff --git a/tests/lib/main.js b/tests/lib/main.js
index 0083ae9..3463ace 100644
--- a/tests/lib/main.js
+++ b/tests/lib/main.js
@@ -23,7 +23,13 @@ describe('SockJS', function() {
       s.close();
     });
 
-    it('should not remove basic authentication credentials', function () {
+    it('should not remove basic authentication credentials (1/2)', function () {
+      var s = new SockJS('http://user@localhost');
+      expect(s).to.have.property('url', 'http://user@localhost');
+      s.close();
+    });
+
+    it('should not remove basic authentication credentials (2/2)', function () {
       var s = new SockJS('http://user:password@localhost');
       expect(s).to.have.property('url', 'http://user:password@localhost');
       s.close();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list