Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added support for implicit http://

  • Loading branch information...
commit 9b4193be187a25c466c9e79c70075656ea3a243c 1 parent 23e473c
@tj authored
Showing with 10 additions and 1 deletion.
  1. +9 −0 lib/utils.js
  2. +1 −1  routes.js
View
9 lib/utils.js
@@ -10,4 +10,13 @@ exports.md5 = function(str) {
.createHash('md5')
.update(str)
.digest('hex');
+};
+
+/**
+ * Imply "http://" for `url`.
+ */
+
+exports.url = function(url){
+ if (~url.indexOf('://')) return url;
+ return 'http://' + url;
};
View
2  routes.js
@@ -33,7 +33,7 @@ app.get('/stats', function(req, res){
*/
app.get('/:url(*)', ratelimit(60, 10), function(req, res, next){
- var url = req.params.url;
+ var url = utils.url(req.params.url);
if (!url) return res.send(400);
var id = utils.md5(url);
var path = join(dir, id + '.png');
Please sign in to comment.
Something went wrong with that request. Please try again.