Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cleaned up api, tests passing

  • Loading branch information...
commit 6bd4c3ebbd784772511f128118454486d68f85da 1 parent 29ef6b4
authored November 26, 2011
9  lib/short.js
@@ -6,21 +6,20 @@ var base = require("base-converter");
6 6
 var ShortURL = require(__dirname + "/../models/ShortURL.js");
7 7
 
8 8
 // setup base62 hash
9  
-function hesher(URL) {
  9
+function hasher(URL) {
10 10
   var id = Math.floor(Math.random() * (100000 - 9999999 + 1) + 9999999);
11 11
   var hash = base.decTo62(id);
12 12
   return hash;
13 13
 };
14 14
 
15  
-var short = function(){};
  15
+module.exports = short = function(){};
16 16
 
17 17
 short.connect = function(mongodb) {
18 18
   mongoose.connect(mongodb);
19 19
 };
20 20
 
21  
-// if it exists, use pre-existing
22 21
 short.gen = function(URL, callback) {
23  
-  var hashedURL = hesher(URL);
  22
+  var hashedURL = hasher(URL);
24 23
   ShortURL.checkExists(hashedURL, function(error, shortenedURLs) {
25 24
     if (error) {
26 25
       callback(error, null);
@@ -54,6 +53,4 @@ short.get = function(hash, callback) {
54 53
   });
55 54
 };
56 55
 
57  
-module.exports = short;
58  
-
59 56
 /* EOF */
2  package.json
@@ -8,7 +8,7 @@
8 8
     "url": "git://github.com/edwardhotchkiss/short.git"
9 9
   },
10 10
   "keywords": ["short", "url", "shortener", "tiny", "uri"],
11  
-  "main": "./index",
  11
+  "main": "./short",
12 12
   "engines": {
13 13
     "node": "~v0.4.11"
14 14
   },

0 notes on commit 6bd4c3e

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