aboutsummaryrefslogtreecommitdiff
path: root/node_modules/https-browserify/index.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/https-browserify/index.js
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
downloadwallet-core-0469abd4a9c9270a1fdc962969e36e63699af8b4.tar.xz
upgrade dependencies
Diffstat (limited to 'node_modules/https-browserify/index.js')
-rw-r--r--node_modules/https-browserify/index.js33
1 files changed, 25 insertions, 8 deletions
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
}