Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated tests and some code cleanup

  • Loading branch information...
commit 649afc9109e838c4443551cc29c1991829ca220c 1 parent 5cf1ba0
Tane Piper authored July 06, 2012
10  bitly.js → index.js
@@ -76,7 +76,7 @@ Bitly.prototype._doRequest = function(request_query, cb) {
76 76
           try {
77 77
             result = JSON.parse(urldata);
78 78
           } catch (exp) {
79  
-            result = {'status_code': 500, 'status_text': 'JSON Parse Failed'}
  79
+            result = {'status_code': 500, 'status_text': 'JSON Parse Failed'};
80 80
           }
81 81
           cb(null, result);
82 82
       });
@@ -93,7 +93,7 @@ Bitly.prototype._doRequest = function(request_query, cb) {
93 93
  */
94 94
 Bitly.prototype._urlCheck = function(str) {
95 95
     var v = new RegExp();
96  
-    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
  96
+    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\\?\/.=]+$");
97 97
     if (!v.test(str)) return false;
98 98
     return true;
99 99
 };
@@ -110,14 +110,14 @@ Bitly.prototype._sortUrlsAndHash = function(items, query) {
110 110
   var i = 0, j = items.length;
111 111
   for(; i < j; i++) {
112 112
     if (this._urlCheck(items[i])) {
113  
-      shortUrl.push(items[i])
  113
+      shortUrl.push(items[i]);
114 114
     } else {
115 115
       hash.push(items[i]);
116 116
     }
117 117
   }
118 118
   if (shortUrl.length > 0) query.shortUrl = shortUrl;
119 119
   if (hash.length > 0) query.hash = hash;
120  
-}
  120
+};
121 121
 
122 122
 /**
123 123
  * Request to shorten one long url
@@ -352,7 +352,7 @@ Bitly.prototype.validate = function(x_login, x_apiKey, cb) {
352 352
   };
353 353
 
354 354
   this._doRequest(this._generateNiceUrl(query, 'validate'), cb);
355  
-}
  355
+};
356 356
 
357 357
 // Export as main entry point in this module
358 358
 module.exports = Bitly;
3  package.json
@@ -2,14 +2,13 @@
2 2
   "name": "bitly",
3 3
   "description": "A Bit.ly API library for Node.JS",
4 4
   "tags": ["url", "bitly", "shortner", "util"],
5  
-  "version": "1.2.3",
  5
+  "version": "1.2.4",
6 6
   "author": "Tane Piper <piper.tane@gmail.com>",
7 7
   "contributors": [
8 8
     { "name": "Tane Piper", "email": "piper.tane@gmail.com" },
9 9
     { "name": "François de Metz", "email": "francois@2metz.fr" },
10 10
     { "name": "zephrax"}
11 11
   ],
12  
-  "main": "./bitly",
13 12
   "repository": {
14 13
     "type": "git",
15 14
     "url": "http://github.com/tanepiper/node-bitly.git"
12  test/index.js
... ...
@@ -1,10 +1,16 @@
1  
-var Bitly = require('../bitly');
  1
+var Bitly = require('../');
2 2
 
3 3
 var bitly_user = 'bitlynodejs';
4 4
 var bitly_key = 'R_8a2a91d31932dc7fda5468033dfe3c15';
5 5
 
6 6
 
7 7
 module.exports = {
  8
+  'test valid url': function(test) {
  9
+    var bitly = new Bitly(bitly_user, bitly_key);
  10
+    test.ok(true, bitly._urlCheck('http://tanepiper.com/test?q=test'));
  11
+    test.done();
  12
+  },
  13
+
8 14
   'shorten url': function(test) {
9 15
     var bitly = new Bitly(bitly_user, bitly_key);
10 16
     bitly.shorten('http://tanepiper.com', function(error, result) {
@@ -218,7 +224,7 @@ module.exports = {
218 224
       test.ifError(error);
219 225
       test.deepEqual(result.status_code, 200);
220 226
       test.done();
221  
-    })
  227
+    });
222 228
   }
223 229
 
224  
-}
  230
+};

0 notes on commit 649afc9

Please sign in to comment.
Something went wrong with that request. Please try again.