Skip to content

Commit a859442

Browse files
stanislaw-grinvengrov
authored andcommitted
fix: critical dependencies error using webpack (#20)
* fix: critical dependencies error using webpack
1 parent 13e63de commit a859442

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libs/backendless.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,11 @@
389389
config.isAsync = (typeof config.isAsync == 'boolean') ? config.isAsync : false;
390390

391391
var protocol = config.url.substr(0, config.url.indexOf('/', 8)).substr(0, config.url.indexOf(":"));
392+
var https = protocol === 'https';
392393

393394
var uri = config.url.substr(0, config.url.indexOf('/', 8)).substr(config.url.indexOf("/") + 2),
394395
host = uri.substr(0, (uri.indexOf(":") == -1 ? uri.length : uri.indexOf(":"))),
395-
port = uri.indexOf(":") != -1 ? parseInt(uri.substr(uri.indexOf(":") + 1)) : (protocol == "http" ? 80 : 443);
396+
port = uri.indexOf(":") != -1 ? parseInt(uri.substr(uri.indexOf(":") + 1)) : (https ? 443 : 80);
396397

397398
var options = {
398399
host : host,
@@ -418,7 +419,7 @@
418419
throw new Error('Use Async type of request using Backendless with NodeJS. Add Backendless.Async(successCallback, errorCallback) as last argument');
419420
}
420421

421-
var httpx = require(protocol);
422+
var httpx = require(https ? 'https' : 'http');
422423

423424
var req = httpx.request(options, function(res) {
424425
res.setEncoding('utf8');

0 commit comments

Comments
 (0)