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