From 0469abd4a9c9270a1fdc962969e36e63699af8b4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 10 Dec 2017 21:51:33 +0100 Subject: upgrade dependencies --- node_modules/https-browserify/index.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'node_modules/https-browserify/index.js') diff --git a/node_modules/https-browserify/index.js b/node_modules/https-browserify/index.js index 853553252..cd203027b 100644 --- a/node_modules/https-browserify/index.js +++ b/node_modules/https-browserify/index.js @@ -1,14 +1,31 @@ -var http = require('http'); +var http = require('http') +var url = require('url') -var https = module.exports; +var https = module.exports for (var key in http) { - if (http.hasOwnProperty(key)) https[key] = http[key]; -}; + if (http.hasOwnProperty(key)) https[key] = http[key] +} https.request = function (params, cb) { - if (!params) params = {}; - params.scheme = 'https'; - params.protocol = 'https:'; - return http.request.call(this, params, cb); + params = validateParams(params) + return http.request.call(this, params, cb) +} + +https.get = function (params, cb) { + params = validateParams(params) + return http.get.call(this, params, cb) +} + +function validateParams (params) { + if (typeof params === 'string') { + params = url.parse(params) + } + if (!params.protocol) { + params.protocol = 'https:' + } + if (params.protocol !== 'https:') { + throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"') + } + return params } -- cgit v1.2.3