Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleaned up api, tests passing

  • Loading branch information...
commit 6bd4c3ebbd784772511f128118454486d68f85da 1 parent 29ef6b4
Edward Hotchkiss authored
Showing with 4 additions and 7 deletions.
  1. +3 −6 lib/short.js
  2. +1 −1  package.json
View
9 lib/short.js
@@ -6,21 +6,20 @@ var base = require("base-converter");
var ShortURL = require(__dirname + "/../models/ShortURL.js");
// setup base62 hash
-function hesher(URL) {
+function hasher(URL) {
var id = Math.floor(Math.random() * (100000 - 9999999 + 1) + 9999999);
var hash = base.decTo62(id);
return hash;
};
-var short = function(){};
+module.exports = short = function(){};
short.connect = function(mongodb) {
mongoose.connect(mongodb);
};
-// if it exists, use pre-existing
short.gen = function(URL, callback) {
- var hashedURL = hesher(URL);
+ var hashedURL = hasher(URL);
ShortURL.checkExists(hashedURL, function(error, shortenedURLs) {
if (error) {
callback(error, null);
@@ -54,6 +53,4 @@ short.get = function(hash, callback) {
});
};
-module.exports = short;
-
/* EOF */
View
2  package.json
@@ -8,7 +8,7 @@
"url": "git://github.com/edwardhotchkiss/short.git"
},
"keywords": ["short", "url", "shortener", "tiny", "uri"],
- "main": "./index",
+ "main": "./short",
"engines": {
"node": "~v0.4.11"
},
Please sign in to comment.
Something went wrong with that request. Please try again.