
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
@gradient/query-array-parser
Advanced tools
Middleware to parse comma separated query params into string arrays.
Middleware to parse comma separated query params into string arrays.
This provides an alternative method for passing arrays as query parameters within express applications.
The default express system requires you to pass up arrays like this:
https://myapp.io?arr=valueOne&arr=valueTwo&arr=valueThree
With this middleware, you can use a comma separated single parameter instead such as this:
https://myapp.io?arr=valueOne,valueTwo,valueThree
npm install @gradient/query-array-parser --save
const express = require('express');
const queryArrayParser = require('@gradient/query-array-parser');
const app = express();
// queryArrayParser accepts either a single string, or an array of
// strings. These strings denote the query parameter name, which will
// be transformed into a string.
app.use(queryArrayParser('categories'));
app.get('/', (req, res, next) => {
// req.params.categories is an array
console.log(req.params.categories);
res.json(req.params.categories).end();
});
app.listen(3000, () => {
console.log('listening');
});
const express = require('express');
const queryArrayParser = require('@gradient/query-array-parser');
const app = express();
// queryArrayParser accepts either a single string, or an array of
// strings. These strings denote the query parameter name, which will
// be transformed into a string.
const options = {
paramNames: ['categories', 'owners'],
delim: ','
};
app.get('/', queryArrayParser(options), (req, res, next) => {
console.log(req.params.categories);
console.log(req.params.owners);
res.json({categories: req.query.categories, tags: req.query.owners});
});
app.listen(3000, () => {
console.log('listening');
});
queryArrayParser takes either a string or an options object as below:
queryArrayParser(string) - The name of the single query parameter that should be parsed with the default delimiter.queryArrayParser(object) - An options objectparamNames - A single string or array of strings denoting the query parameter(s) to be parsed.delim - The delimiter that will be used in the query parameters to be parsed. Defaults to ,.Copyright (c) 2017 Gradient Limited - Released under the MIT license.
FAQs
Middleware to parse comma separated query params into string arrays.
We found that @gradient/query-array-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.