Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eh-api-client

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eh-api-client - npm Package Compare versions

Comparing version 0.7.3 to 0.7.4

20

index.js

@@ -15,2 +15,16 @@ var

function _url(data) {
if(typeof data === "string") {
return data;
}
if(data instanceof Array) {
var url = data.shift();
url = url.replace(/\?\?/g, function() {
return encodeURIComponent(data.shift());
});
return url;
}
throw new Error("url should be a string or an array");
}
var methods = [

@@ -34,3 +48,3 @@ "GET",

Client.prototype.fork = function(subUrl) {
apiURL = this.apiURL + subUrl;
apiURL = this.apiURL + _url(subUrl);
var newClient = new Client(apiURL, this._options);

@@ -45,3 +59,3 @@ return newClient;

}
if(typeof options === "string") {
if(typeof options === "string" || (options instanceof Array)) {
options = {

@@ -58,3 +72,3 @@ url: options

var reqParams = {
url: this.apiURL + options.url,
url: this.apiURL + _url(options.url),
method: method,

@@ -61,0 +75,0 @@ json: true,

2

package.json
{
"name": "eh-api-client",
"version": "0.7.3",
"version": "0.7.4",
"description": "Node.js rest client",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,2 +8,3 @@ var

var client = f.getClient(1, "web");
var enc = encodeURIComponent;

@@ -79,2 +80,17 @@ describe("Internal Auth Client test", function() {

});
it("should fork client with placeholders in URL", function() {
var fork = client.fork(["/blabla/??/??", "///&%&*", "&&*^$$$!@$//?"]);
fork.apiURL.should.equal(client.apiURL + "/blabla/" + enc("///&%&*") + "/" + enc("&&*^$$$!@$//?"));
});
it("should request url with placeholders", function(done) {
client.get(["/test/??/??", "///&%&*", "&&*^$$$!@$//?"], {
test: true
}, function(err, req) {
should.not.exists(err);
req.url.should.equal("http://localhost:3000/test/" + enc("///&%&*") + "/" + enc("&&*^$$$!@$//?"));
done();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc