Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add support for https image urls

  • Loading branch information...
commit 17187e54f436aa52054cdb67d7fdfb492458e895 1 parent 95faca7
@bumi bumi authored
Showing with 14 additions and 4 deletions.
  1. +14 −4 index.js
View
18 index.js
@@ -1,4 +1,5 @@
http = require('http')
+https = require('https')
fs = require('fs')
url = require('url')
@@ -16,10 +17,19 @@ function fetch(query,cb){
function download(match, output, addText){
fetch(match, function(file){
- var host = url.parse(file).hostname
- , path = url.parse(file).pathname
-
- request = http.get({host: host, path: path}, function(res){
+ if(!match) {
+
+ }
+ var uri = url.parse(file)
+ var host = uri.hostname
+ , path = uri.pathname
+
+ if(uri.protocol == "https:")
+ var r = https;
+ else
+ var r = http;
+
+ request = r.get({host: host, path: path}, function(res){
res.setEncoding('binary')
var img = ''
Please sign in to comment.
Something went wrong with that request. Please try again.