jscrambler
Advanced tools
Comparing version 5.2.8 to 5.2.9
@@ -45,2 +45,4 @@ 'use strict'; | ||
var debug = !!process.env.DEBUG; | ||
/** | ||
@@ -135,7 +137,8 @@ * @class JScramblerClient | ||
// Format URL | ||
var protocol = this.options.protocol || (this.options.port === 443 ? 'https' : 'http'); | ||
var port = this.options.port || (this.options.protocol === 'http' ? 80 : 443); | ||
var protocol = this.options.protocol || (port === 80 ? 'http' : 'https'); | ||
var formatedUrl = _url2.default.format({ | ||
hostname: this.options.host, | ||
port: this.options.port, | ||
port: port, | ||
protocol: protocol | ||
@@ -170,7 +173,22 @@ }) + path; | ||
return promise.then(function (res) { | ||
if (res.status >= 200 && res.status < 400) { | ||
return res.data; | ||
return res.data; | ||
}).catch(function (err) { | ||
var errorMessage = 'Unexpected Response: '; | ||
if (err.response) { | ||
if (debug) { | ||
console.error(err.response); | ||
} | ||
errorMessage += err.response.status + ' ' + err.response.statusText; | ||
// For when we have API error messages | ||
if (err.response.data && err.response.data.error && err.response.data.message) { | ||
errorMessage += ' - ' + err.response.data.message; | ||
} | ||
} else { | ||
errorMessage += err.message; | ||
} | ||
throw new Error('Unexpected Response Code: ' + res.status); | ||
throw new Error(errorMessage); | ||
}); | ||
@@ -177,0 +195,0 @@ }; |
@@ -17,6 +17,5 @@ 'use strict'; | ||
keys: {}, | ||
host: 'api4.jscrambler.com', | ||
port: 443 | ||
host: 'api4.jscrambler.com' | ||
}, []); | ||
exports.default = config; |
{ | ||
"name": "jscrambler", | ||
"description": "Jscrambler API client.", | ||
"version": "5.2.8", | ||
"version": "5.2.9", | ||
"homepage": "https://github.com/jscrambler/jscrambler", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -13,3 +13,3 @@ # ![jscrambler](https://rawgithub.com/jscrambler/javascript-jscrambler/master/media/jscrambler-logo.png) | ||
- [Quick example](#quick-example) | ||
- [JScrambler Parameters](#jscrambler-parameters) | ||
- [Jscrambler Parameters](#jscrambler-parameters) | ||
@@ -16,0 +16,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108003
2392
9