From 0b220ced8f15c8b681c7ee5b7e08a2d8e1c51e2f Mon Sep 17 00:00:00 2001 From: Flummi Date: Sun, 14 Aug 2016 02:20:26 +0200 Subject: [PATCH] modified: src/main.js --- src/main.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main.js b/src/main.js index 8bf6180..47086da 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,7 @@ var cfg = require('../../cfg.json'); var fs = require('fs'); +var http = require('http'); +var https = require('https'); var mysql = require('mysql'); var bot = require('coffea')(); const path = require('path'); @@ -52,7 +54,7 @@ var getUser = (u, n) => { var dl = (url, dest, cb) => { var file = fs.createWriteStream(dest); - var request = adapterFor(url).get(url, (response) => { + var request = (url.match(/^https/)?https:http).get(url, (response) => { try { response.pipe(file); file.on('finish', () => { @@ -69,15 +71,4 @@ var dl = (url, dest, cb) => { e.reply(ex); } }); -} - -var adapterFor = (function() { - var url = require('url'), - adapters = { - 'http:': require('http'), - 'https:': require('https'), - }; - return (inputUrl) => { - return adapters[url.parse(inputUrl).protocol] - } -}()); \ No newline at end of file +} \ No newline at end of file