Socket
Socket
Sign inDemoInstall

url-assembler

Package Overview
Dependencies
16
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

13

lib/url-assembler-factory.js

@@ -14,2 +14,6 @@ var extend = require('extend');

var query = {};
//For future to keep other configs
this._config = {
qsConfig: {}
};
this._query = addQueryParamTo(query);

@@ -45,2 +49,3 @@ this._prefix = '';

self._prefix = instance._prefix;
self._config = instance._config;
self._query(instance.getParsedQuery());

@@ -62,2 +67,8 @@ self._requestModule = instance._requestModule;

methods.qsConfig = function(config) {
var chainable = this._chain();
extend(chainable._config.qsConfig, config);
return chainable;
};
methods.segment = function (segment) {

@@ -117,3 +128,3 @@ var chainable = this._chain();

}
this.search = qs.stringify(query);
this.search = qs.stringify(query, this._config.qsConfig);
}

@@ -120,0 +131,0 @@

8

package.json
{
"name": "url-assembler",
"version": "2.0.0",
"version": "2.1.0",
"description": "Assemble urls from route-like templates (/path/:param)",

@@ -8,3 +8,3 @@ "main": "index.js",

"scripts": {
"test": "istanbul cover --print detail _mocha -- -R spec test",
"test": "nyc -r text -r html -r lcov mocha -R spec test",
"coveralls": "cat coverage/lcov.info | coveralls"

@@ -39,4 +39,4 @@ },

"coveralls": "^3.0.2",
"istanbul": "^0.4.5",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"proxyquire": "^1.4.0",

@@ -46,5 +46,5 @@ "sinon": "^1.14.1"

"dependencies": {
"extend": "^2.0.0",
"extend": "^2.0.2",
"qs": "^6.5.1"
}
}

@@ -151,2 +151,7 @@ [![Build Status][travis-image]][travis-url] [![Coverage][coveralls-image]][coveralls-url]

###### `.qsConfig(config)`
- add config supported by qs.stringify https://www.npmjs.com/package/qs version ^6.5.1
###### `.toString()`, `.valueOf()`, `toJSON()`

@@ -153,0 +158,0 @@ - **returns** a *string* of the current state of the `UrlAssembler` instance. Path parameters not yet replaced will appear as `:param_name`.

@@ -68,2 +68,19 @@ var expect = require('chai').expect

describe("when baseUrl has a repeated query param with config", function() {
beforeEach(function() {
myUrl = UrlAssembler("http://domain.com/coucou?hello=world");
});
it("should keep accept qs config options", function() {
expect(
myUrl
.qsConfig({
arrayFormat: "repeat"
})
.query("a", ["b", "c"])
.toString()
).to.equal("http://domain.com/coucou?hello=world&a=b&a=c");
});
});
describe('when used with special characters', function() {

@@ -70,0 +87,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc