[Pkg-javascript-commits] [sockjs-client] 164/434: Fix #8. Throw exception on missing url.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:11 UTC 2014


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

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

commit 75198b9c50b813dc75896326200538092aae7b96
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Tue Oct 11 17:30:12 2011 +0100

    Fix #8. Throw exception on missing url.
---
 lib/utils.js                | 8 +++++---
 tests/html/src/tests.coffee | 6 ++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/utils.js b/lib/utils.js
index 296a131..41dee37 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -321,8 +321,9 @@ utils.bind = function(fun, that) {
 
 utils.amendUrl = function(url) {
     var dl = _document.location;
-    // falsy url means use current document location as url
-    if (!url) url = dl;
+    if (!url) {
+        throw new Error('Wrong url for SockJS');
+    }
     //  '//abc' --> 'http://abc'
     if (url.indexOf('//') === 0) {
         url = dl.protocol + url;
@@ -331,7 +332,8 @@ utils.amendUrl = function(url) {
     if (url.indexOf('/') === 0) {
         url = dl.protocol + '//' + dl.host + url;
     }
-    url = url.replace(/[/]+$/,''); // strip trailing slashes
+    // strip trailing slashes
+    url = url.replace(/[/]+$/,'');
     return url;
 };
 
diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index cfcf641..3c791ab 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -344,6 +344,12 @@ test "amending url", ->
     r = new SockJS('http://a:1/abc//', [])
     equal(r._base_url, 'http://a:1/abc')
 
+    t = ->
+        new SockJS('', [])
+    raises(t, 'Wrong url')
+    t = ->
+        new SockJS(false, [])
+    raises(t, 'Wrong url')
 
 test "EventEmitter", ->
     expect(4)

-- 
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